Hello, i just started with on my new school and we are going to make an application that ask how old you are.
If you're 13 to 19year old it should say ''Teenager''
But if you write for example 8, it should say '' little kid ".
I started to script some, but i dont get it to work. I know im a noob or what you want to call me, but i just want to make it work :)
Here is the codes.

#include <iostream>

using namespace std;

int main () {
int age;
cout <<"How old are you?:";
cin >>age;

if(age ">12" and "<19"){
cout << " You're an teenager ";
}
else { 
cout << " little kid ";
}
}

Many thanx if you help me :)

Hello, i just started with on my new school and we are going to make an application that ask how old you are.
If you're 13 to 19year old it should say ''Teenager''
But if you write for example 8, it should say '' little kid ".
I started to script some, but i dont get it to work. I know im a noob or what you want to call me, but i just want to make it work :)
Here is the codes.

#include <iostream>

using namespace std;

int main () {
int age;
cout <<"How old are you?:";
cin >>age;

if(age ">12" and "<19"){
cout << " You're an teenager ";
}
else { 
cout << " little kid ";
}
}

Many thanx if you help me :)

if(age ">12" and "<19"){

Get rid of the quotes. Also, you need the variable age before each < or > symbol not just the first. Finally, don't use the word "and", use the symbol && which means "and".

if (age > 12 && age < 19){

I thank you so much VernonDozier.
Finnaly got this working, not much wrong in the code to be honest.
Thank you ! <3

#include <iostream>
using namespace std;

int main ()
{
    int age;
    cout <<"How old are you?:";
    cin >> age;

    if(age > 12 && age < 19)
    {
        cout << " You're an teenager ";
    }
    else if(age > 18)
    {
        cout << " You're pretty old ";
    }
    else
    { 
        cout << " You're a little kid ";
    }
}

Also indenting makes the code easier to read.

This article has been dead for over six months. Start a new discussion instead.