This will be the output:
and this will be the code:
# include <iostream>
using namespace std;
int main ()
{
char one, two;
cout<<"Enter code Player 1: "; cin>>one; cout<<endl;
cout<<"Enter code Player 2: "; cin>>two; cout<<endl;
if (one == 'c' && two == 'p')
{cout<<"Player 1 wins!"; cout<<endl;}
else if (one == 'c' && two == 's')
{cout<<"Player 2 wins!"; cout<<endl;}
else if (one == 'c' && two == 'c')
{cout<<"It's a TIE!"; cout<<endl;}
else if (one == 'p' && two == 'c')
{cout<<"Player 2 wins!"; cout<<endl;}
else if (one == 'p' && two == 's')
{cout<<"Player 1 wins!"; cout<<endl;}
else if (one == 'p' && two == 'p')
{cout<<"It's a TIE!"; cout<<endl;}
else if (one == 's' && two == 'c')
{cout<<"Player 1 wins!"; cout<<endl;}
else if (one == 's' && two == 'p')
{cout<<"Player 2 wins!"; cout<<endl;}
else if (one == 's' && two == 's')
{cout<<"It's a TIE!"; cout<<endl;}
cout<<endl;
system ("pause");
}
Beginners code in Programming
Tuesday, November 12, 2013
Tuesday, October 22, 2013
zodiac sign code in c++
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:
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:
Sunday, October 20, 2013
Passed or Failed Grade code in c++
This will be the output:
if passed:
if failed:
This will be the code:
# include <iostream>
using namespace std;
int main ()
{
int score;
cout<<"Enter your score: "; cin>>score; cout<<endl;
if (score >= 90)
{
cout<<"You got an A*"; cout<<endl;
cout<<"You Passed"; cout<<endl;
}
else if (score >= 80)
{
cout<<"You got an A"; cout<<endl;
cout<<"You Passed"; cout<<endl;
}
else if (score >= 70)
{
cout<<"You got a B*"; cout<<endl;
cout<<"You Passed"; cout<<endl;
}
else if (score >= 60)
{
cout<<"You got a C"; cout<<endl;
cout<<"You Passed"; cout<<endl;
}
else if (score >= 50)
{
cout<<"You got a D"; cout<<endl;
cout<<"You Passed"; cout<<endl;
}
else if (score >= 40)
{
cout<<"You got a D"; cout<<endl;
cout<<"You Failed"; cout<<endl;
}
else if (score >= 30)
{
cout<<"You got a E"; cout<<endl;
cout<<"You Failed"; cout<<endl;
}
else if (score >= 20)
{
cout<<"You got a F"; cout<<endl;
cout<<"You Failed"; cout<<endl;
}
else if (score >= 10)
{
cout<<"You got a G"; cout<<endl;
cout<<"You Failed"; cout<<endl;
}
else if (score >= 1)
{
cout<<"You got a H"; cout<<endl;
cout<<"You Failed"; cout<<endl;
}
cout<<endl;
system ("pause");
} .post {-webkit-user-select: none; -khtml-user-select: none; -moz-user-select: -moz-none; -ms-user-select: none; user-select: none;}
if passed:
if failed:
This will be the code:
# include <iostream>
using namespace std;
int main ()
{
int score;
cout<<"Enter your score: "; cin>>score; cout<<endl;
if (score >= 90)
{
cout<<"You got an A*"; cout<<endl;
cout<<"You Passed"; cout<<endl;
}
else if (score >= 80)
{
cout<<"You got an A"; cout<<endl;
cout<<"You Passed"; cout<<endl;
}
else if (score >= 70)
{
cout<<"You got a B*"; cout<<endl;
cout<<"You Passed"; cout<<endl;
}
else if (score >= 60)
{
cout<<"You got a C"; cout<<endl;
cout<<"You Passed"; cout<<endl;
}
else if (score >= 50)
{
cout<<"You got a D"; cout<<endl;
cout<<"You Passed"; cout<<endl;
}
else if (score >= 40)
{
cout<<"You got a D"; cout<<endl;
cout<<"You Failed"; cout<<endl;
}
else if (score >= 30)
{
cout<<"You got a E"; cout<<endl;
cout<<"You Failed"; cout<<endl;
}
else if (score >= 20)
{
cout<<"You got a F"; cout<<endl;
cout<<"You Failed"; cout<<endl;
}
else if (score >= 10)
{
cout<<"You got a G"; cout<<endl;
cout<<"You Failed"; cout<<endl;
}
else if (score >= 1)
{
cout<<"You got a H"; cout<<endl;
cout<<"You Failed"; cout<<endl;
}
cout<<endl;
system ("pause");
} .post {-webkit-user-select: none; -khtml-user-select: none; -moz-user-select: -moz-none; -ms-user-select: none; user-select: none;}
Subscribe to:
Posts (Atom)