473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

i have a unqualifiedified-id

hi in line 8 I have a unqualifiedified-id I do not understand that heres the
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main();
  6. int john;
  7. int name;
  8. {
  9. count<< "pleas type your name :\n";
  10. cin>>name;
  11. cin.ignore();
  12. {if (name==john) count<<"I like your name\n"; else if (name!=john) count<<"notcool\n";
  13.  
  14. }
  15. }
Dec 9 '11 #1
1 991
Banfa
9,065 Expert Mod 8TB
Line 5: no ; at the end of main, that makes it a declaration instead of a definition.

Line 6 and 7: You can't declare variables here if you want global variables then put them before main, if you want variables local to main put them after the {

Line 12: Strange and unnecessary { with matching partner on line 14

Line 12: Comparison of john to name. Works because both are integers but john is uninitialised so the results are unpredictable.

Line 12: if (name == john) ... else if (name != john) second condition is unrequired, if name isn't equal to john if necessarily must be not equal to john just use if (name == john) ... else

Line 12: Code squished onto 1 line makes it unreadable

Program: variables john and name suggest they are used to hold peoples names but they are integers and therefore hold numbers. Variable typing is wrong or variable naming convention is confusing.
Dec 9 '11 #2

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

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.