using if and else if
here's the code in making a zodiac in c++:
# include <iostream>
using namespace std;
int main ()
{
int month, date;
cout<<"Enter your numerical month: "; cin>>month; cout<<endl;
cout<<"Enter your numerical date: "; cin>>date; cout<<endl;
if (month == 3 && date >= 21 || month == 4 && date <= 20)
{ cout<<"Your sign is Aries"; cout<<endl;}
else if (month == 4 && date >= 21 || month == 5 && date <= 21)
{ cout<<"Your sign is Taurus"; cout<<endl;}
else if (month == 5 && date >= 22 || month == 6 && date <= 22)
{ cout<<"Your sign is Gemini"; cout<<endl;}
else if (month == 6 && date >= 23 || month == 7 && date <= 23)
{ cout<<"Your sign is Cancer"; cout<<endl;}
else if (month == 7 && date >= 24 || month == 8 && date <= 23)
{ cout<<"Your sign is Leo"; cout<<endl;}
else if (month == 8 && date >= 24 || month == 9 && date <= 23)
{ cout<<"Your sign is Virgo"; cout<<endl;}
else if (month == 9 && date >= 24 || month == 10 && date <= 23)
{ cout<<"Your sign is Libra"; cout<<endl;}
else if (month == 10 && date >= 24 || month == 11 && date <= 22)
{ cout<<"Your sign is Scorpio"; cout<<endl;}
else if (month == 11 && date >= 24 || month == 12 && date <= 21)
{ cout<<"Your sign is Saguittarius"; cout<<endl;}
else if (month == 12 && date >= 22 || month == 1 && date <= 20)
{ cout<<"Your sign is Capricorn"; cout<<endl;}
else if (month == 1 && date >= 21 || month == 2 && date <= 19)
{ cout<<"Your sign is Aquarius"; cout<<endl;}
else if (month == 2 && date >= 20 || month == 3 && date <= 20)
{ cout<<"Your sign is Pieces"; cout<<endl;}
cout<<endl;
system ("pause");
}
This will be the output:
sangat berguna sekali artikelnya terimah kasih banyak atas infonya
ReplyDeleteini sangat membantu saya,terimakasih banyak
ReplyDeletegod idea
Delete