#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
// simple program using y - n char's yesNO - could be what you want though.
int main()
{
char yesNO;
cout << "Are you an illegal immigrant? y - n: ";
cin >> yesNO;
if (yesNO=='y'
{
cout << "OMG - your an illegal immigrant... calling the police";
return 0;
}
if (yesNO=='n'
{
cout << "Good Your a Fine Civilian ";
return 0;
}
if (yesNO < 'n', 'y'
{
cout << "Closing...";
return 0;
}
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
// simple program using y - n char's yesNO - could be what you want though.
int main()
{
char yesNO;
cout << "Are you an illegal immigrant? y - n: ";
cin >> yesNO;
if (yesNO=='y'
{
cout << "OMG - your an illegal immigrant... calling the police";
return 0;
}
if (yesNO=='n'
{
cout << "Good Your a Fine Civilian ";
return 0;
}
if (yesNO < 'n', 'y'
{
cout << "Closing...";
return 0;
}
}
[ /PHP ] to add color to your code.
[php]
#include <iostream>
//cstdlib not used here
//cmath not used here
using namespace std;
// simple program using y - n char's yesNO - could be what you want though.
int main()
{
char yesNO; //beter name would be "userInput" as this decribes what it stores
cout << "Are you an illegal immigrant? y - n: ";
cin >> yesNO;
if (yesNO=='y'
{
cout << "OMG - your an illegal immigrant... calling the police";
}
else if (yesNO=='n' //else if means, "ok if its not y, is it?" this enables us to do
{
cout << "Good Your a Fine Civilian ";
}
else //ethis enables us to do else, meaning, ok its not y, and its no n, so do this
{
cout << "Closing...";
}
system("PAUSE"); // a way of pausing the application instead of it ending instantly.
return 0; //return 0 can be moved to end of code, as theres no need repeating it in definite outcomes.
}
[ /PHP ] to add color to your code.
[php]
#include <iostream>
//cstdlib not used here
//cmath not used here
using namespace std;
// simple program using y - n char's yesNO - could be what you want though.
int main()
{
char yesNO; //beter name would be "userInput" as this decribes what it stores
cout << "Are you an illegal immigrant? y - n: ";
cin >> yesNO;
if (yesNO=='y'
{
cout << "OMG - your an illegal immigrant... calling the police";
}
else if (yesNO=='n' //else if means, "ok if its not y, is it?" this enables us to do
{
cout << "Good Your a Fine Civilian ";
}
else //ethis enables us to do else, meaning, ok its not y, and its no n, so do this
{
cout << "Closing...";
}
system("PAUSE"); // a way of pausing the application instead of it ending instantly.
return 0; //return 0 can be moved to end of code, as theres no need repeating it in definite outcomes.
}
system("pause");
right before all of the
return 0;
statements. Otherwise the program will immediately shut down after clicking enter.
Copyright © 2024, NextGenUpdate.
All Rights Reserved.