0% found this document useful (0 votes)
2 views7 pages

CS101_E_Quiz_3

This document is a quiz for CS101 Introduction to Computing and Programming, consisting of 20 questions related to programming concepts and C++ syntax. Each question presents a code snippet or concept and asks for the expected output or correct answer. The quiz is designed to assess students' understanding of programming fundamentals within a 30-minute time limit.

Uploaded by

Sam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

CS101_E_Quiz_3

This document is a quiz for CS101 Introduction to Computing and Programming, consisting of 20 questions related to programming concepts and C++ syntax. Each question presents a code snippet or concept and asks for the expected output or correct answer. The quiz is designed to assess students' understanding of programming fundamentals within a 30-minute time limit.

Uploaded by

Sam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Quiz # 3

CS101 Introduction to Computing and Programming

Max. Time 30 minutes

Name: - _______________________Reg. No. : - _______________ Sec: - E

1- What should be the output of the following program?

#include <iostream>
using namespace std;
int main()
{ int a;
a = 5 + 3 * 5;
cout << a;
return 0;
}
a) 35
b) 20
c) 25
d) 30
2- What is this operator called?:?
a) Conditional
b) Relational
c) Casting operator
d) None of the mentioned

3- What should be the output of the following program?

#include<iostream>
using namespace std;
int operate (int a, int b)
{
return (a * b);
}
float operate (float a, float b)
{
return (a / b);
}
int main ()
{
int x = 5, y = 2;
float n = 5.0, m = 2.0;
cout << operate (x, y);
cout << operate (n, m);
return 0;
}

a) 119 b) 102.5 c) None of the mentioned d)123.4


Name: ____________________ Reg. No: _______________

4- If the variable count exceeds 100, a single statement that prints “Too many” is
a) if (count<100) cout << “Too many”;
b) if (count>100) cout >> “Too many”;
c) if (count>100) cout << “Too many”;
d) None of these.

5- Consider the following statements:


int x = 22, y=15 ;

x = (x>y) ? (x+y) : (x-y);

What will be the value of x after executing these statements?

a) 22
b) 37
c) 7
d) Error. Cannot be executed

6- What should be the output of the following program?

int main()
{
int new = -10;
cout<<"new is: "<<new;
return 0;
}
a) new is: -10
b) new is: 10
c) Compilation Error
d) new is: 0

7- Which operator is having the highest precedence?

a) postfix
b) unary
c) shift
d) equality

8- How many types of loops are there?

a) 4
b) 2
c) 3
d) 1
Name: ____________________ Reg. No: _______________

9- What should be the output of the following program?

int main()
{
int i = 0, x = 0;
do
{
if(i % 5 == 0)
{
cout<<x;
x++;
}
++i;
}while(i<10);
cout<<x;
return 0;
}
a) 01
b) 012
c) 0
d) 0123

10- What should be the output of the following program:

#include <iostream>
using namespace std;
void mani()
void mani()
{
cout<<"hai";
}
int main()
{
mani();
return 0;
}
a) hai
b) haihai
c) compile time error
d) run time error
Name: ____________________ Reg. No: _______________

11- What should be the output of the following program:

#include <iostream>
using namespace std;
void fun(int x, int y)
{
x = 20;
y = 10;
}
int main()
{
int x = 10;
fun(x, x);
cout<< x;
return 0;}

a) 10
b) 20
c) compile time error
d) none of the mentioned

12- What should be the output of the following program:

#include <iostream>
using namespace std;
int main ()
{
int x, y;
x = 5;
y = ++x * ++x;
cout<< x << y;
x = 5;
y = x++ * ++x;
cout<< x << y;
return 0;
}

a) 749736
b) 736749
c) 367497
d) none of the mentioned
Name: ____________________ Reg. No: _______________

13- What should be the output of the following program:

#include <iostream>
using namespace std;
int main()
{
int i, j;
j = 10;
i = ( j++, j + 100, 999 + j);
cout<<i;
return 0;
}

a) 1000
b) 11
c) 1010
d) 1001

14- What should be the output of the following program:

int main()
{
int i=0,x=0;
for(i=1;i<10;i*=2)
{
x++;
cout<<x;
}
cout<<x;
return 0;
}

a) 1234567899
b) 12345678910
c) 123455
d) 12344

15- Which of the following must be present in switch construct?

a) Expression in ( ) after switch


b) default
c) case followed by value
d) All of these
Name: ____________________ Reg. No: _______________

16- Assigning one or more function body to the same name is called

a) Function Overriding
b) Function Overloading
c) Both a and b
d) Function Overlapping

17- What is the output of below program?

int main()
{
if(0)
{
cout<<"Hi";
}
else
{
cout<<"Bye";
}
return 0;
}
a) Hi
b) Bye
c) HiBye
d) Compilation Error

18- What is the output of below program?


#include<iostream.h>
void Execute(int &x, int y = 200)
{
int TEMP = x + y;
x+= TEMP;
if(y!=200)
cout<<TEMP<<x<<y"--";
}

int main()
{
int A=50, B=20;
cout<<A<<B<<"--";
Execute(A,B);
cout<<A<<B<<"--";
return 0;
}
a) 5020--5020-- b) 5020--7012020--12020--
c) 5020--70120200—5020 d) 5020--7050200--5020—
Name: ____________________ Reg. No: _______________

19- The library function exit() causes an exit from

a)The loop in which it occurs


b)The block in which it occurs
c) The function in which it occurs
d) The program in which it occurs

20- What will be the value of variable “number” ?

#include <iostream>
#include <string>
using namespace std;
string askNumber(string str = "Please enter a number: ");
int main()
{
string number = askNumber();
cout << "Here is your number: " << number;
return 0;
}
string askNumber(string str)
{
string number;
cout << str;
cin >> number;
return number;
}

a) 5
b) 6
c) the number you entered
d) compile time error

You might also like