You are on page 1of 11

Nelson Jamila

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 << "Character ";


cout << "The size of char is: " << sizeof(char) << " byte/s"<< endl;
sleep(4);

cout << "Boolean ";


cout << "The size of bool is: " << sizeof(bool) << " byte/s" << endl;
sleep(4);

cout << "Float ";


cout << "The size of float is: " << sizeof(float) << " byte/s" << endl;
sleep(4);

cout << "Integer ";


cout << "The size of int is: " << sizeof(int) << " byte/s" << endl;
sleep(4);

cout << "Double ";


cout << "The size of double is: " << sizeof(double) << " byte/s" << endl;
sleep(4);

cout << "long Double ";


cout << "The size of long Double is: " << sizeof(long double) << " byte/s" << endl;
sleep(4);

cout << "\nArithmetic Operator/s: " << endl;

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 << "\nRelational operators " << endl;


sleep(4);
cout << "Operator Description " << endl;
sleep(3); // 3 seconds
cout << "== Equal to" << endl;
sleep(3);
cout << "!= Not equal to" << endl;
sleep(3);
cout << "< Less than" << endl;
sleep(3);
cout << "> Greater than" << endl;
sleep(3);
cout << "<= Less than or equal to" << endl;
sleep(3);
cout << ">= Greater than or equal to" << endl;
sleep(3);

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";
}

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 or equal to the second number (<=) \n";
}else if (e>=f){
cout << "first number is greater than or equal to the second number (>=) \n";
}
sleep (4);

cout << "\nLogical Operators " << endl;


sleep (5);

cout << "! operator " << endl;


cout << "The operator ! is the C++ operator for the Boolean operation NOT.";
cout << "It has only one operand, to its right, and inverts it, producing false if its operand
is true, and true if its operand is false.";
cout << "Basically, it returns the opposite Boolean value of evaluating its operand.";

cout << "\nEXAMPLES \n" << endl;


sleep
(3);
cout << "!(5 == 5) // evaluates to false because the expression at its right (5 == 5) is
true" << endl; sleep (3);
cout << "!(6 <= 4) // evaluates to true because (6 <= 4) would be false" << endl;
sleep (3);
cout << "!true // evaluates to false" << endl;
sleep (3);
cout << "!false // evaluates to true " << endl;
sleep (6); // 6 seconds

cout << "\n&& operator\n" << endl; sleep (4);


cout << "Explanation: " << endl; sleep (3);
cout << " A B Sagot" << endl; sleep (3);
cout << "TRUE TRUE = TRUE" << endl; sleep (3);
cout << "TRUE FALSE = FALSE" << endl; sleep (3);
cout << "FALSE TRUE = FALSE" << endl; sleep (3);
cout << "FALSE FALSE = FALSE" << endl; sleep (3);
cout << "( (5 == 5) && (3 > 6) ) // evaluates to false ( true && false )" << endl;
sleep(4);

cout << "\n|| operator\n" << endl; sleep (4);


cout << "Explanation: " << endl; sleep (3);
cout << " A B Sagot" << endl; sleep (3);
cout << "TRUE TRUE = TRUE" << endl; sleep (3);
cout << "TRUE FALSE = TRUE" << endl; sleep (3);
cout << "FALSE TRUE = TRUE" << endl; sleep (3);
cout << "FALSE FALSE = FALSE" << endl; sleep (3);
cout << "( (5 == 5) || (3 > 6) ) // evaluates to true ( true || false ) " << endl;
sleep(4);
cout << "\nConditional Statements\n" << endl;

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);

cout << "\nThe else Statement\n" << endl;

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);

cout << "\nThe else if Statement\n" << endl;

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);

cout << "\nSwitch Statements\n" << endl;


sleep(4);

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;
}

cout << "\nWhile Loop\n" << endl;

int i = 0;
int number;
cout << "Input number: ";
cin >>number;

while (i < number) {


cout << i << "\n";
i++;
}

cout << "\nDo While Loop\n" << endl;

cout << "Input number: ";


int j = 0;
int numbers;
cin >> numbers;
do {
cout << j << "\n";
j++;
}
while (j < numbers);

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

cout << "For Loop \n" << endl;

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;
}

You might also like