Professional Documents
Culture Documents
BSIT 1C
#include <iostream>
#include <unistd.h>
using namespace std;
main (){
int a,b;
float c,d;
int e,f;
cout << "These are the data types: " << endl;
sleep(4);
cout << "The + operator add its operands " << endl;
cout << "Enter first number: ";
cin >> a;
cout << "Enter second number: ";
cin >> b;
cout << "The sum (+) of first and second number is: " << a+b << endl;
sleep(4);
cout << "\nThe - operator subtracts second operand to the first " << endl;
cout << "Enter first number: ";
cin >> a;
cout << "Enter second number: ";
cin >> b;
cout << "The difference (-) of first and second number is: " << a-b << endl;
sleep(4);
cout << "\nThe * operator multiplies its operands " << endl;
cout << "Enter first number: ";
cin >> a;
cout << "Enter second number: ";
cin >> b;
cout << "The product (*) of first and second number is: " << a*b << endl;
sleep(4);
cout << "\nThe / operator divides the first operand to the second " << endl;
cout << "Enter first number: ";
cin >> c;
cout << "Enter second number: ";
cin >> d;
cout << "The quotient (/) of first and second number is: " << c/d << endl;
sleep(4);
cout << "\nThe % operator finds the modulus of its first operand with respect to the
second" << endl;
cout << "it produces the ""REMAINDER"" of dividing the first by the second " << endl;
cout << "Enter first number: ";
cin >> a;
cout << "Enter second number: ";
cin >> b;
cout << "The modulus (%) of first and second number is: " << a%b << endl;
sleep(4);
cout << "\n""Mini Interaction for Relational Operators"" " << endl;
cout << "\nFor operators == and != " << endl;
cout << "Enter first number: ";
cin >> e;
cout << "Enter second number: ";
cin >> f;
if (e==f){
cout << "first and second number are Equal (==) \n";
}else if (e!=f){
cout << "first and second number are Not Equal (!=) \n";
}
cout << "\nFor operators < and >" << endl;
cout << "Enter first number: ";
cin >> e;
cout << "Enter second number: ";
cin >> f;
if (e<f){
cout << "first number is less than the second number (<) \n";
}else if (e>f){
cout << "first number is greater than the second number (>) \n";
} else {
cout << "first and second number are equal \n";
}
sleep(4);
cout << "The if Statement\n" << endl;
sleep(4);
cout << "Use the if statement to specify a block of C++ code to be executed if a condition
is true." << endl; sleep(6);
cout << " if (20 > 18) {" << endl;
cout << " cout << \"20 is greater than 18\";" << endl;
cout << " }\n" << endl;
sleep(11);
cout << " if (100 > 90) {" << endl;
cout << " cout << \"100 is greater than 90\";" << endl;
cout << " }\n" << endl;
sleep(11);
sleep(4);
cout << "Use the else statement to specify a block of code to be executed if the condition
is false." << endl; sleep(6);
cout << " int time = 20;" << endl;
cout << " if (time < 18) {" << endl;
cout << " cout << \"Good day.\";" << endl;
cout << " } else {" << endl;
cout << " cout << \"Good evening.\";" << endl;
cout << " }" << endl;
cout << "Answer is Good evening (which is false)(condition)" << endl; sleep(11);
sleep(4);
cout << "Use the else if statement to specify a new condition if the first condition is
false." << endl; sleep(6);
cout << "13 - 18 ay teen at 19 - 100 ay adult" << endl;
sleep(4);
cout << " int age = 22;" << endl;
cout << " if (age < 12) {" << endl;
cout << " cout << \"Baby\";" << endl;
cout << " } else if (age < 19) {" << endl;
cout << " cout << \"Teen\";" << endl;
cout << " } else {" << endl;
cout << " cout << \"Adult\";" << endl;
cout << " }" << endl;
cout << "Answer is Adult (this case is adult age)" << endl; sleep(12);
int day;
cout << "Input number from 1 to 7 : ";
cin >> day;
switch (day) {
case 1:
cout << "Monday \n";
break;
case 2:
cout << "Tuesday \n";
break;
case 3:
cout << "Wednesday \n";
break;
case 4:
cout << "Thursday \n";
break;
case 5:
cout << "Friday \n";
break;
case 6:
cout << "Saturday \n";
break;
case 7:
cout << "Sunday \n";
break;
}
int i = 0;
int number;
cout << "Input number: ";
cin >>number;
cout << "Input number: (hint: higher than the previous input) : ";
int k;
int num = 3;
cin >> k;
do {
cout << k << "\n";
k++; //increment
}
while (k < num); //condition
sleep(4);
cout << "Syntax" << endl;
cout << " for (statement 1; statement 2; statement 3) {" << endl;
cout << " // code block to be executed" << endl;
cout << " }" << endl;
sleep(6);
cout << "Statement 1 is executed (one time) before the execution of the code block." <<
endl; sleep(4);
cout << "Statement 2 defines the condition for executing the code block." << endl;
sleep(4);
cout << "Statement 3 is executed (every time) after the code block has been executed."
<< endl; sleep(4);
int n;
int m;
cout << "Input starting value (n): ";
cin >> n;
cout << "Input end value (m): ";
cin >> m;
for (int f=n;n <= m; n++){
cout << n << "\n";
}
cout << "THANK YOU FOR USING MY PROGRAM (END)" << endl;
}