Solved i dont understand why i got the error

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

zzlazyzz

Newbie
Full Member
Jan 21, 2014
6
142
0
#include <iostream>

using namespace std;


int main()
{
int x = 10;
int y = 5;
cout << "x = 10";
cin >> x = 10;
cout << "y = 5";
cin >> y = 5;
cout << x << "+" << y << "=" << x + y << endl;

return 0;
}

Error:

C:\HACKS\Ch.3Practice2\main.cpp|11|error: no match for 'operator=' in 'std::cin.std::basic_istream<_CharT, _Traits>::eek:perator>><char, std::char_traits<char> >((* & x)) = 10'|

C:\HACKS\Ch.3Practice2\main.cpp|13|error: no match for 'operator=' in 'std::cin.std::basic_istream<_CharT, _Traits>::eek:perator>><char, std::char_traits<char> >((* & y)) = 5'|
 

rN'

Jr.Hacker
Meme Tier VIP
Jan 19, 2014
340
6,268
41
std::cin is an Input command..

C++:
#include <iostream>

using namespace std;

int main( void )
{
	int Number1 = 0;
	int Number2 = 0;

	cout << "Enter your first Number:";
	cin >> Number1;
	cout << "Enter your seconed Number:";
	cin >> Number2;
	cout << "The total sum of " << Number1 << " and " << Number2 << " is " << Number1 + Number2 << endl;
        cout << "The difference of " << Number1 << " and " << Number2 << " is " << Number1 - Number2 << endl;
	
	system( "pause" );
	return 0;
}
 
Last edited:

Rake

I'm not your friend
Administrator
Jan 21, 2014
12,508
78,998
2,419
This was your code:
C++:
#include <iostream>

using namespace std;


int main()
{
int x = 10;
int y = 5;
cout << "x = 10";
cin >> x = 10;
cout << "y = 5";
cin >> y = 5;
cout << x << "+" << y << "=" << x + y << endl;

return 0;
}
I think you just need to read and practice more, I'm not sure you're understanding the basics just yet but you will!

Line 1-7 no problems.
Line 8 & 9 you declare 2 integers and assign them respective values.
Line 10&12 you ouput your message in quotations to the screen. If the value of x & y change the cout only prints your message, not the correct values.
But for practicing the basics that is fine.
Line 11 & 13 are the lines with your errors. I'm not sure you understand how to use them.
Line 14-17 are fine.

In fact line 11 & 13 aren't neccesary for this program to run because you don't need any input because you've already assigned values to the variables x & y.

Here is the code line with 11 & 13 removed. I added "<< endl;" to your cout lines so it will look better on the screen. So no input is necessary -- your next step would be to have this program take input from the user for the values of x & y.

C++:
#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
	int x = 10;
	int y = 5;
	cout << "x = 10" <<endl;
	cout << "y = 5" << endl;
	cout << x << "+" << y << "=" << x + y << endl;

	return 0;
}
Good luck!
 
Last edited:
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods