Professional Documents
Culture Documents
General Instructions
1. Rewrite the following set of statements after removing all the errors (two errors each
program): (2)
a. void main()
cin>>a, b;
if(a= =b)
cout<<a*break;
getch();
b. void main()
clrscr;
int x,y;
switch(x)
case 1.5:
cout<<”hello”;
case 2:
cout<<”welcome’;
case 3:
case 4:
cout<<”Windows”;
getch();
cin>>a>>b;
if(a= =b)
cout<<a*br;
getch();
clrscr();
int x,y;
cin>>x;
switch(x)
case 1:
cout<<”hello”;
case 2:
cout<<”welcome’;
case 3:
case 4:
cout<<”Windows”;
getch();
2. What will be the output for the following code of statements? (7)
a. void main()
char str[20];
cin>>str;
gets(str);
getch();
b. void main()
char a=’z’;
int b=a;
cout<<b<<endl<<b+3;
c. void main()
cout<<c;
d. void main()
char a;
switch (a)
case ‘A’:
case ‘B’:
cout<<” Sunday”<<endl<<”Monday”;
break;
case ‘C’:
case ‘D’:
cout<<”Tuesday”;
break;
case ‘E’:
cout<”Thursday”;
break;
getch();
e. void main()
int x=20;
f. void main()
cout<<”Input Device”;
cout<<”Output Device”;
getch();
g. void main()
c=a/b;
d=a%b;
void main()
char d;
int a,b,c, d;
cin>>a>>b>>d;
switch(d)
case ‘+’:
c=a+b;
break;
case ‘-‘:
c= a-b;
break;
case ‘*’:
case ‘#’:
c=a*b;
break;
default:
cout<<”Invalid Input”;
break;
getch();
void main()
int a,b,c,x;
cin>>x>>a>>b;
a+=100;
a= b+900;
cout<<a<<b;
a= b+100;
b=a+900;
cout<<b<<a;;
else
cout<<”invalid input”;
getch();
char d;
int a,b,c, d;
if(d==’+’)
c=a+b;
else if (d==’-‘)
c= a-b;
c=a*b;
else
cout<<”Invalid Input”;
getch();
b) void main()
int a,b,c,x;
cin>>x>>a>>b;
switch(x)
case 100:
case 200:
a+=100;
cout<<a<<b;
break;
case 300:
a= b+900;
cout<<a<<b;
break;
case 400:
a= b+100;
b=a+900;
cout<<b<<a;;
break;
default:
cout<<”invalid input”;
getch();
a. (288)10 to Binary
b. (11011101)2 to Decimal
c. (145)16 to Decimal
d. (174)10 to octal
Ans. a. 100100000
b. 221
c. 325
d. 256
a. Variables
b. Logical Operator
b. Logical Operator: operators used to set relation between the operands and execute the
statements accordingly.
c. Fundamental data type: data types that are not composed of any other data type
d. Name the two types of conditional statements used in C++. Also write any two differences
between them.
Ans. a. ++a: operation which means change the operand first and then use it whereas a++
b.
c.
d.
can check multiple variables simultaneously only one variable checking at a time
e. Software : programs and data inside the system. Language processors are the translators
that convert machine language into low and high level language and vice versa.