Computer Programming theory Quiz 1


QUIZ NO. 01

Date:    /   /2017
Time: 20 Minutes
Total Marks: 10
Obtained Marks: _______
Registration No:
___________
Student_Name:
____________________________________

1.      Mark the following statements as true or false.                                                         [ 3 Marks]
a.      A linker links and load the object code from main memory into the CPU for execution. False
b.      A compiler translates the source program into an object code.                                          True
c.       A program that written in high level programming language is called a source program. True
d.      In c++ there is no difference between a reserve word and a predefined identifier.             False
e.       If a =b ; and b= 3; then after the statement a = b ; the value of b is still 3?.                       True
f.       To use the predefined function of setw in a program , the programmust include the header file imanip.h.                                                                                                                             False

2.      Given:                                                                                                                             [ 2 Marks]
int num1 , num2, newNum;
double x ,y ;
which of the following assignments are valid?

num1 * num2 = newNum;
InValid
x = x + y -5;
Valid
num1 = 5 ; num2 = 2 + num1; num1 = num2 / 3;
Valid
num1 = 35
Valid


3.      Evalute the following expression.                                                                                [ 1 Mark]
a.      5/9 * (32.6 -4.5)
b.      18.0 + 5.0 * 3.0 / 4.0
18.0 + 5.0 * 3.0 / 4.0
18.0 + 15.0 / 4.0
18.0 + 3.33
22.25
5/9 * (32.6 -4.5)

0.5 * (28.1)

14.5


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<<”product\tof“<<x<<”and”<<z<<”is”
<<x*z<<endl;
 Product of 8 and 5 is 40
Cout<<”x+y/z = “ << x+y/z<<endl;
  x + y /z = 2.6
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]



using namespace std;
include <#iostream>

int main()
{
int num1, num2;
string str1;

cout<<”enter string without any blanks in it “:;
cin>>string
cout<<endl;

cout<<”enter two integers:”;
cin<< num1 , num2;
cout<<end;

return 0;

cout<<str1 <<” “ << “num1 * num2 = “ << num1 * num2 << endl;
}
using namespace std;
#include<iostream>

int main()
{
int num1, num2;
string str1;

cout<<”enter string without any blanks in it;”;
cin>>str1;
cout<<endl;

cout<<”enter two integers:”;
cin >>num1 >> num2;
cout<<endl;


cout<<str1 <<” “ << “num1 * num2 = “ << num1 * num2 << endl;

return 0;

}



Comments

Popular posts from this blog

Computer Programming Lab 5

Computer Programming lab 11

Computer Programming Lab 4