473,504 Members | 13,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error message 'non-lvalue in assignment', any suggestions?

5 New Member
Expand|Select|Wrap|Line Numbers
  1. #pragma hdrstop
  2. #include <conio.h>
  3. #include <ctype.h>
  4. #include <iostream>
  5.  
  6. #pragma argsused
  7.  
  8. //-------------------------------------------------------
  9.  
  10. using namespace std;
  11. int main ( ) { 
  12. int i;
  13. int x;
  14. std::cout << "\nPlease enter an even number:";
  15. cin >> x;
  16. if(x%2=1)
  17.          std::cout << "\nNumber entered was not even.";
  18. else
  19.     std::cout << "\nNimber entered was " <<x<< ".";
  20.     std::cout << "\n\nNext ten even values: ";
  21. for (i=0; i<=8; i++) 
  22. {
  23.      x=x+2;
  24.      std::cout <<x<< " "; 
  25. }
  26. x=x+2;
  27. std::cout <<x<< ".";
  28. getch();
  29. return 0;
  30. }
  31.  
This my code and the problem is with the if statement. That's when the error message appears :(
Oct 21 '11 #1
2 4816
millman
5 New Member
Don't worry, i worked it out myself but just incase anyone else has a similar problem you need two equals signs like this == in the if statement. Also if you use windows visual c++ you need this header file. #include <StdAfx.h>
Oct 21 '11 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
You only need <stdafx.h> is you have a Win32 application as opposed to a Win32 Console Application project where you have created as empty and not using precompiled headers.
Oct 22 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3660
by: James | last post by:
Hello Java NG, I not sure if this is the right NG for this type of question but if not please let me know which is, TIA Any way first off let me say I'm a student and this WAS last weeks lab,...
9
9467
by: Bob Stearns | last post by:
When trying an alter I am getting: DB2 SQL error: SQLCODE: -20054, SQLSTATE: 55019, SQLERRMC: IS3.SERVICE_OBS;22 Message: The table "IS3.SERVICE_OBS" is in an invalid state for the operation. ...
3
2762
by: Matthew Louden | last post by:
Access is denied. Description: An error occurred while accessing the resources required to serve this request. You might not have permission to view the requested resources. Error message...
1
2505
by: Clark Choi | last post by:
I ran the sample application called Petstore from msdn. Everything went fine until I tested Update button on the web form to update the database through Datagrid. I have been searching the web to...
14
2362
by: Roland Hall | last post by:
Since I'm not getting any response from the community, I'm reposting this under my managed account. I've turned my web.config friendly error messages off and it may be easier to view what I'm...
0
952
by: robgale | last post by:
Hi, I'm trying to access an msde database on my dedicated server but I keep getting an error message that I can't find any information about. A search on Google reveals just one mention of the...
1
1579
by: Jeremy Ames | last post by:
I have a datagrid that updates the table using a stored procedure. The stored procedure is confirmed to complete correctly, yet the sql data adapter is returning an error that my application is...
8
2835
by: Taras_96 | last post by:
Hi everyone, We' ve come to the conclusion that we wish the user to be directed to an error page if javascript is disabled <enter comment about how a webpage shouldn't rely on javascript here :)...
3
2236
by: dancer | last post by:
I am using Framework 1.1.4322. Who can tell me why I'm getting this error? My code follows Compilation Error Description: An error occurred during the compilation of a resource required to...
2
3485
by: Jonathan Crawford | last post by:
Hi I made a small change to a .Net 2 framework website and uploaded it today and went to the site and got Parser Error Message: Could not load type 'Tgsi.CortijoRomero.Website.Global'....
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.