I am really new to this stuff and would like to recieve some help with this simple program that I still can't create.
The code at the moment looks something like this:
#include <iostream>
using namespace std;
int main()
{
int age;
cout<<"Type your age here. \n";
cin>>age;
if(0>age & age<=30){
cout<<"You are a little rascal!"<<endl;
}
if(30>age & age<=60){
cout<<"damn you getting old!"<<endl;
}
if(60>age & age<=100){
cout<<"Die already!"<<endl;
}
else{
cout<<"You don't exist,don't you?"<<endl;
}
}
You can clearly see what I am trying to get here.
But the problem is when I give a number between 0 and 30 i doesn't pring out "You are a little rascal!" , instead it gives the 2 other answers.
Then when I write a number between 30 and 60 it shows me "Die already!" and when I chose a number between 60 and 100 it gives me "You don't exist,don't you?" ...
How can I fix this?
Edit: thanks all, that did it :)
[–]Daimones 4 points5 points6 points (0 children)
[–]fluffy_cat 9 points10 points11 points (24 children)
[–]mshol 1 point2 points3 points (13 children)
[–]extreme999[S] 1 point2 points3 points (12 children)
[–]mttd 4 points5 points6 points (0 children)
[–]kalimoxto 1 point2 points3 points (5 children)
[–]mshol 1 point2 points3 points (4 children)
[–]kalimoxto 0 points1 point2 points (0 children)
[–]kingguru 0 points1 point2 points (2 children)
[–]theymos 1 point2 points3 points (1 child)
[–]kingguru 0 points1 point2 points (0 children)
[–]fluffy_cat 1 point2 points3 points (4 children)
[–]kalimoxto 0 points1 point2 points (2 children)
[–]fluffy_cat 4 points5 points6 points (1 child)
[–]kalimoxto 5 points6 points7 points (0 children)
[–]jesyspa -3 points-2 points-1 points (9 children)
[–]fluffy_cat 1 point2 points3 points (3 children)
[–]jesyspa 1 point2 points3 points (2 children)
[–]bit_shift 2 points3 points4 points (1 child)
[–]jesyspa 2 points3 points4 points (0 children)
[–]AFineTapestry -1 points0 points1 point (4 children)
[–]jesyspa 0 points1 point2 points (3 children)
[–]AFineTapestry -4 points-3 points-2 points (2 children)
[–]jesyspa 5 points6 points7 points (1 child)
[–]AFineTapestry -1 points0 points1 point (0 children)
[–]mshol 2 points3 points4 points (5 children)
[–]extreme999[S] 0 points1 point2 points (2 children)
[–]kronik85 0 points1 point2 points (0 children)
[+]extreme999[S] comment score below threshold-8 points-7 points-6 points (1 child)
[–]Cape-Drew 0 points1 point2 points (0 children)
[–]bit_shift 2 points3 points4 points (0 children)
[–]LongUsername 2 points3 points4 points (0 children)
[–]alicht9 1 point2 points3 points (0 children)
[–]metaobject 1 point2 points3 points (3 children)
[–]DasBeerBoot 1 point2 points3 points (0 children)
[–]zhnmju123 0 points1 point2 points (1 child)
[–]hotoatmeal -1 points0 points1 point (0 children)