Another view notes to your code: void main() is only supported by some Microsoft compilers. Use int main() instead. Use else ifs rather than a lot of ands: Fixed code
#include<iostream>
usingnamespace std;
int main()
{
int a;
cout<<"What is ur age?"<<endl;
cin>>a;
if (a<=10)
{
cout<<"u r a kid dude!!!"<<endl;
}
elseif (a<=20)
{
cout<<"Hi gorgeous"<<endl;
}
elseif (a<30)
{
cout<<"bachay sumbhal.......yahan kia kr raha hay"<<endl;
}
elseif (a<50)
{
cout<<"Get a Job!!!!!!!"<<endl;
}
elseif (a<70)
{
cout<<"Reading Newspaper is my passion!!!"<<endl;
}
elseif (a<=100)
{
cout<<"This is it Sir!!!!!!!"<<endl;
}
}
EDIT:
Another problem you might be describing is the fact that the console closes unexpectedly at the end. Just add some pausing code: http://www.cplusplus.com/forum/beginner/1988/
OK. Your 1st problem: There actually is some output in the console, you just can't see it - you haven't told the compiler to hold, and so it displays the console after you type something in and closes it immediately. In order to keep the result on the screen type in:
getch();
(remember to add #include <conio.h> in headers section);
The other problem you haven't spotted is that you mixed up your closing braces - here's how it should look like i hope you can spot the mistake:
What is this? - a new generation super-extra multimedia player or a stupid console program?
No, a forum to learn people how to code. That includes doing it the RIGHT way from the beginning, not unlearning habits. Unportability (and therefor getch()) is one of these bad habits. Throwing away better solutions (using functionality that is already implemented because you included the iostream library) is another one.
I agree. cin.get() is a superior solution for this problem than getch(), and even stupid console programs will benefit. Please don't get on the defensive; we're only trying to help here, and suggesting getch() when one can use cin.get() is generally not seem as helpful around here, and for a good reason too. :(
I'm assuming that was sarcasm; it's good to use DirectX, if that's the way to go for your solution. When we are discussing on the beginners sub-forum, we try to keep things as open as possible (just as in the General C++ sub-forum). If this thread was posted in the Windows programming sub-forum, getch() would be an option. Still, it's not negligible that cin.get() does the job good (and is already included into the code) and thus it's not good practice to include conio.h, too.
I'm assuming that was sarcasm; it's good to use DirectX, if that's the way to go for your solution. When we are discussing on the beginners sub-forum, we try to keep things as open as possible (just as in the General C++ sub-forum). If this thread was posted in the Windows programming sub-forum, getch() would be an option. Still, it's not negligible that cin.get() does the job good (and is already included into the code) and thus it's not good practice to include conio.h, too.
+1
ok i've already stated my opinion stop looking for a fight.
-1
Why you assuming he's looking for a fight, please take your retarded comments elsewhere.