Homework #3

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Glenn Gutierrez 12

CST 2403-E339

H/W #3

Prof: Elhari Oct 04, 13


1. To print the sum, difference, product, quotient and 2# using cin.

#include <iostream>
//ggprog11
//Print the sum, difference, product and quotient of 2 numbers using cin
using namespace std;

int main()

{
int a,b;
cout<<"Enter 2 Numbers:"<<endl;
cin>>a>>b;
cout<<"Sum="<<a+b<<endl;
cout<<"Product="<<a*b<<endl;
cout<<"Difference="<<a-b<<endl;
cout<<"Quotient="<<a/b<<endl;
system ("pause");
return 0;

2. To print the sum, difference, product, quotient using assignment statement.

#include <iostream>
using namespace std;
//ggprog12
//Print the sum, different, product, and quatient of 2 numbers using cin and
assignment statements.
int main()
{
int a,b;
cout<< "Enter two numbers:" <<endl;
cin>>a>>b;
cout<< "Sum=="<<a+b<<endl;
cout<< "Product=="<<a*b<<endl;
cout<< "Difference=="<<a-b<<endl;
cout<< "Quotient=="<<a/b<<endl;
system ("pause");
return 0;
}

3. Define
Relationals The binary relational operators determine the following like less than, greater than,
less than or equal to and greater than or equal to.

Condition - The conditional operator evaluates an expression returning a value if the expression
is true and if a different one if the expression is false.

Logical Operator - A logical operator in C++ are mostly of signs that are not part of the
alphabet but are available in keyboards. This makes C++ code shorter and more international.

Start
4a
Read A

Read B

Sum A+B

Print Sum

End

Start
4b
Read A,B

Is A>B

Print B Print A

End

You might also like