Computer Programming Theory Quiz 1A
|
|
QUIZ NO. 01
|
|
||||||
|
Date: / /2017
|
Time: 20 Minutes
|
Total Marks: 10
|
Obtained Marks: _______
|
|||||
|
Registration No:
|
___________
|
Student_Name:
|
____________________________________
|
|||||
1.
Mark
the following statement as true or false. [ 3 Marks]
a.
The first step in the problem solving
process is to analyse the problem. True
b.
Processing of c++ program include six steps.
True
c.
An identifier can be any sequence of digits
and letters. True
d.
The operands of modulus operator must be
integers.
True
e.
Suppose x = 5 .after the statement y = x++; executes y is 5 and x is 6 . True
f.
Suppose pay is a variable of type double.the
statement cin>>pay; requires the input of a decimal number. True
2.
Given:
[
2 Marks]
int num1 ,
num2, newNum;
double x ,y ;
which of the
following assignments are valid?
|
num1 = 35
|
Valid
|
|
x = 12
* num1 – 15.5;
|
Valid
|
|
num1 = 5 ; num2 = 2 + num1; num1 = num2 / 3;
|
Valid
|
|
x/ y = x* y;
|
Invalid
|
3. Evalute the following expressions .
[ 1 Marks]
a.
28-3+6
b.
15 + 18 % 2 – 20 / 6
|
4. Suppose x , y ,and z are int
variables and x =8 , y = 3 and z = 5.what is the output of
the following c++ statements
[ 2 Marks]
|
Cout<<”x=”<<x<<”,y =
“<<y<<”,z=”
<<z<<endl;
|
x = 8 , y = 3 , z=5
|
|
cout<<”x+3*y=”<<x+3*y<<endl;
|
x= 3 *y = 17
|
|
Cout<<”product\tof“<<x<<”and”<<z<<”is”
<<x*z<<endl;
|
Product of 8 and 5 is 40
|
|
cout<<setw(10)<<setfill(‘‘)<<“x=:”
<<x<<endl;
|
x=:8
|
5. The following program has syntax errors.
Correct them. On each successive line, assume that any preceding error has been
corrected. [
2 Marks]
|
const char = STAR = ‘*’
const int PRIME = 71;
int main()
{
int count , sum ;
double x;
count = 1;
sum = count
+ PRIME;
x = 25.67
newNum = count * one + 2;
sum + count = sum;
(x + sum)++;
x = x + sum
* COUNT;
Sum += 3 --;
cout<< “count =” << count << “,
sum = <<”, PRIME = “ << prime << endl;
}
|
const char
STAR = ‘*’;
const int PRIME = 71;
int main()
{
int one =1 ,
newNum;
int count , sum ;
double x;
count = 1;
sum = count + PRIME;
x = 25.67;
newNum = count * one + 2;
sum += count;
int z = x +
sum;
z++;
x = x +
sum * count;
int y =3 ;
y--;
sum += y;
cout<<
“count =” << count << “, sum = “<<sum <<”, PRIME = “
<< PRIME << endl;
return 0;
}
|
Comments
Post a Comment