Introduction To Programming
Question No 1:
Write a program that ask the user to enter the two numbers,
obtain the two numbers from the user and print the sum, product, difference and
quotient of the two numbers
Question No 2:
Write a program that print the numbers 1 to four on the same
line with each pair of adjacent numbers separated by one space. Do this several
ways
a)
Using one
statement with one stream insertion operator (i.e. <<)
b)
Using one
statement with four stream insertion operator
c)
Using
four separate statements
Question No 3:
Write a program that asks the user to enter two integers,
obtain the number from the user, then print larger number followed by the words
“is larger” if the numbers are equal, print the message “these numbers are
equal”
Type the following code, compile and
run with different inputs shown below
Question No 4:
#include
<iostream>
using namespace std;
main()
{
double
currentpay = 0.0;
double
raiserate = 0.0;
double
raise = 0.0;
double
newpay = 0.0;
cout<<"enter
current weekly pay:";
cin>>currentpay;
cout<<"enter
raiserate" ;
cin>>raiserate;
raise
= currentpay * raiserate;
newpay
= raise + currentpay;
cout<<"newpay:
" <<newpay<<endl;
}
Give the
following inputs and write corresponding o utputs
Current
weekly pay = 1000 newpay:=
_________________
Rate
raise = 0.25
Current
weekly pay = 5000 new
pay := ________________
Rate
raise = 0.20
Current
weekly pay = 1657.90 new
pay := _________________
Rate
raise = 0.10
Question No 5:
#include
<iostream>
using namespace std;
main()
{
int
number1;
int
number2;
cout<<"enter
two numbers to comapre";
cin>>
number1 >> number2;
if(number1==number2)
cout<<number1<<"=="
<<number2<<endl;
if(number1!=number2)
cout<<number1<<
"!"<<number2<<endl;
if(number1<number2)
cout<<number1<<"<"
<<number2<<endl;
}
Give the
following inputs and write corresponding outputs
Number 1
= _______ output:
= _________________
Number 2
= _______
Number 1
= ______ output:
= ________________
Number 2
= _______
Number 1
= _______ output:
= _________________
Number 2
= _____________
Question No 6:
: Write a C++ assignment
statement that multiplies the number 9.55 by the value stored in an int
variable named hours and then assigns the result to a double variable named
grossPay. Use implicit type conversion.
Question No 7:
: Rewrite the answer
to Question 1 using a type cast (explicit type conversion).
Instructions:
· Solve all questions and save them according question no.
· Make a folder with your name. copy .cpp file in that folder
and make it .rar or zip file and email me at sadafkamboh66@gmail.com till
Sunday night 4/12/2016 at 11:00 P.M.
· There will be mini quiz in class so bring your laptop with
you.
· Late submitted assignment will not be marked.
0 comments:
Post a Comment