You are on page 1of 4

Question1

1.1

Int var1 = 4;

Int var2 = 10;

Int newVal = 0;

newVal = var2 – var1*2;

=10-4*2;

newVal=2;

1.2

a =5;

Case1: a=5+3=8;

Case3: a=8*3=24;

Case5: a=++a+10;

= ++5+10;

=6+10=16;

Case6: a /= 2=16/2=8;

Default: a=a+1=8+1=9;

a= 9;

1.3

Int findValue( int numberP)

Int count = 0;

Int value = 20;

While (count < numberP)


{

value += count;

count++

return value;

Cout << findValue(3);

FindValue=26;

Question 2

Int a,b,c;

Cin >> a>>b>>c;

Cout << c+b+c;

2.1

The code's purpose is to display and find unknown values of S using values from variable
N, which start from 0 to 5.

2.2

The code’s purpose is to display the values of integer C when i is above 0.

Question 3

Line3:

a valueP

2 6

Line4: a valueP count

2 6 0
Line7: a valueP count

3 6 0

Line8: a valueP count

3 6 2

Returna;

Line7: a valueP count

6 6 2

Line8: a valueP count

6 6 4

Returna;

Line7: a valueP count

13 6 4

Line8: a valueP count

13 6 6

Since count is no longer less than ValueP we exit the execution of the loop.

Question4

#include <iostream>

Using namespace std;

Int main( )

Int NoOfRegnt;
float feePPerson, amntComOwesSem;

Cout << “Input the number of registants(if the user enter a number that is less or
“equal to zero an error message should be displayed):” << endl;

noOf

If ((noOfregnt !=0) && (1 <= noOfRegnt <= 4))

You might also like