You are on page 1of 2

Answers q4 2017 2018

1. (1) Write a single statement to assign 0 to variable total, subtotal, average, tax and shipping
Total=stotal=ave=tax=shipping=0.0

2. (1) What is the result of executing following codes :


Int a=2; b=5;c=0;
c=++(a*b);

Ans : its an error

3. (2) Write an input validation loop that ask user to enter integer between 10 through 25

Int var, again=1;

While( again ==1)


{

Cin << var;


if ( var <10 II var > 25 ) again=1

Else
again=0;

4. (2) Write your name and passport number to a file called students.txt

5. (2) What is the result if following codes :


Int count=0;
while ( count++ < 10)
{
if ( count%2 ==0) continue;
Else
Count << “ counting …”<<count<<endl;
}
Answer : it writes counting .. 1 ( from 1,3,5,7,9)

6. (4) Void addThree( int &, int &, int &, int &)
The above statement is a prototype. Write a function which
sum = ( num1+num2)*2+num3;

Answer :
Void sumit( int &sum, int&n1, int &n2, int &num3)
{
Sum=( n1+n2)*2+num3;
}

7. Void test(int=2, int=4,int=6), write 3 function call for this prototype

a. test() .. all default value


b. test( a ) .. first argument passed
c. text ( a,b) .. first and second argument passed

You might also like