wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quality Assessment - 20CS1001 Programming for Problem Solving

Total questions: 100

Worksheet time: 1hrs 21mins

Name
Class
Date
1.

In the following loop construct, which one is executed only once always.

for(exp1; exp2; exp3)

a)

exp1

b)

exp3

c)

exp1 and exp3

d)

exp1,exp2 and exp3

2.

The continue statment cannot be used with

a)

for

b)

while

c)

do while

d)

switch

3.

goto can be used to jump from main to within a function?

a)

true

b)

false

c)

-

d)

-

4.

Which loop is guaranteed to execute at least one time.

a)

for

b)

while

c)

do while

d)

none of the above

5.

A labeled statement consist of an identifier followed by

a)

:

b)

;

c)

?

d)

=

6.

c = (n) ? a : b; can be rewritten asexp1 ? exp2 : exp3;

a)

if(n){c = a;}else{c = b;}

b)

if(!n){c = a;}else{c = b;}

c)

if(n){c = b;}else{c = a;}

d)

None of the above

7.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

while ()

printf("In while loop ");

printf("After loop\n");

}

a)

In while loop after loop

b)

After loop

c)

Compile time error

d)

Infinite loop

8.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

do{

printf("In while loop ");

}while (0);

printf("After loop\n");

}

a)

In while loop

b)

In while loop after loop

c)

After loop

d)

Infinite loop

9.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int i = 0;

do {

i++;

printf("In while loop\n");

} while (i < 3);

}

a)

In while loop

In while loop

In while loop

b)

In while loop

In while loop

c)

Depends on the compiler

d)

Compile time error

10.

#include <stdio.h>

int main()

{

int i = 0;

do {

i++;

printf("in while loop\n");

} while (i < 3);

}

a)

2

b)

3

c)

4

d)

1

11.

#include <stdio.h>

int main()

{

int i = 0;

while (i < 3)

{

i++;

printf("In while loop\n");

}

}

a)

2

b)

3

c)

4

d)

1

12.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int i = 0;

do

{

printf("Hello");

} while (i != 0);

}

a)

Nothing

b)

H is printed infinite times

c)

Hello

d)

Run time error

13.

#include<stdio.h>

int main()

{

int i;

for(i=0;i<10;i++);

printf("%d ",i);

}

a)

0 1 2 3 4 5 6 7 8 9

b)

Compile Error

c)

Run Time Error

d)

10

14.

Is it possible to run program without main() function?

a)

yes

b)

no

c)

-

d)

-

15.

What is output of below program?


int main()

{

int i,j,count;

count=0;

for(i=0; i<5; i++);

{

for(j=0;j<5;j++);

{

count++;

}

}

printf("%d",count);

}

a)

55

b)

54

c)

1

d)

0

16.

int main()


{


int a = 10, b = 25;


a = b++ + a++;


b = ++b + ++a;


printf("%d %d n", a, b);


}

a)

36 64

b)

35 62

c)

36 63

d)

30 28

17.

#include<stdio.h>

int main()

{

float a=0.7;

if(a<0.7)

{

printf("C");

}

else

{

printf("C++");

}

}

a)

C

b)

C++

c)

Compilation Error

d)

None of the these

18.

int main() {


int m = -10, n = 20;


n = (m < 0) ? 0 : 1;


printf("%d %d", m, n);


}

a)

-10 0

b)

10 20

c)

20 -10

d)

0 1

19.

#include<stdio.h>

int main()

{

int a=2,b=7,c=10;

c=a==b;

printf("%d",c);

}

a)

0

b)

7

c)

2

d)

Compilation error

20.

What is the output of C Program.?

int main()

{

int a=5;

while(a >= 3);

{

printf("RABBIT\n");

break;

}

printf("GREEN");

return 0;

}

a)

GREEN

b)

RABBIT GREEN

c)

RABBIT is printed infinite times

d)

None of the above

21.

What is the output of C Program.?

int main()

{

int a=25;

while(a <= 27)

{

printf("%d ", a);

a++;

}

return 0;

}

a)

25 25 25

b)

25 26 27

c)

27 27 27

d)

Compiler error

22.

What is the output of C Program.?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

}

while(a <= 30);

return 0;

}

a)

32

b)

33

c)

30

d)

No Output

23.

What is the output of C Program.?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

if(a > 35)

break;

}

while(1);

return 0;

}

a)

No Output

b)

32 33 34

c)

32 33 34 35

d)

Compiler error

24.

Choose a correct C Statement.

a)

a++ is (a=a+1) POST INCREMENT Operator

b)

a-- is (a=a-1) POST DECREMENT Operator

--a is (a=a-1) PRE DECREMENT Operator

c)

++a is (a=a+1) PRE INCREMENT Operator

d)

All the above.

25.

What is the output of C Program.?

int main()

{

int k;

for(;;)

{

printf("TESTING\n");

break;

}

return 0;

}

a)

No Output

b)

TESTING

c)

Compiler error

d)

None of the above

26.

What is the way to suddenly come out of or Quit any Loop in C Language.?

a)

continue; statement

b)

break; statement

c)

leave; statement

d)

quit; statement

27.

Choose correct C while loop syntax.

a)

while(condition) { //statements }

b)

{ //statements }while(condition)

c)

while(condition); { //statements }

d)

while() { if(condition) { //statements } }

28.

Choose a correct C for loop syntax.

a)

for(initalization; condition; incrementoperation) { //statements }

b)

for(declaration; condition; incrementoperation) { //statements }

c)

for(declaration; incrementoperation; condition) { //statements }

d)

for(initalization; condition; incrementoperation;) { //statements }

29.

What is the output of C Program.?

int main()

{

int a=5;

while(a==5)

{

printf("RABBIT");

break;

}

return 0;

}

a)

RABBIT is printed unlimited number of times

b)

RABBIT

c)

Compiler error

d)

None of the above.

30.

What is the output of C Program.?

int main()

{

int a=5;

while(a=123)

{

printf("RABBIT\n");

break;

}

printf("GREEN");

return 0;

}

a)

GREEN

b)

RABBIT GREEN

c)

RABBIT is printed unlimited number of times.

d)

Compiler error.

31.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int i = 0;

do {

i++;

printf("In while loop\n");

} while (i < 3);

}

a)

In while loop

In while loop

In while loop

b)

In while loop

In while loop

c)

Depends on the compiler

d)

Compile time error

32.
Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
a)
rem = 3.14 % 2.1;
b)
rem = modf(3.14, 2.1);
c)
rem = fmod(3.14, 2.1);
d)
Remainder cannot be obtain in floating point division
33.
Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and not to others.
a)
Yes
b)
No
34.
In which order do the following gets evaluated
1.Relational
2.Arithmetic
3.Logical
4.Assignment
a)
2134
b)
1234
c)
4321
d)
3214
35.
The keyword used to transfer control from a function back to the calling function is
a)
switch
b)
goto
c)
go back
d)
return
36.
The modulus operator cannot be used with a long double.
a)
True
b)
False
37.

Every C Program Statement must be terminated with a

a)

.

b)

#

c)

;

d)

!

38.

What does the following code fragment write to the monitor?

a)

Under

b)

Over

c)

Under the limit

d)

Over the limit

39.

What does the following code fragment write to the monitor?

a)

Under

b)

Over

c)

Under the limit

d)

Over the limit

40.

Evaluate(to true or false) each of the following expressions:

(1) 14 <= 14

(2) 14 < 14

a)

false false

b)

true true

c)

true false

d)

false true

41.

When applied to a variable, what does the unary "&" operator yield?

a)

The variable's address

b)

The variable's right value

c)

The variable's binary form

d)

The variable's value

42.

The operator "&" is used for

a)

Bitwise AND

b)

Bitwise OR

c)

Logical AND

d)

Logical OR

43.

The operator "&" is used for

a)

Bitwise AND

b)

Bitwise OR

c)

Logical AND

d)

Logical OR

44.

The size of a character variable in C is

a)

8 bytes

b)

4 bytes

c)

2 bytes

d)

1 byte

45.

The words if, else, auto, float etc. have predefined meaning and users cannot use them as variables.


These words are called

a)

keywords

b)

identifier

c)

data types

d)

constant

46.

Which operators are used to compare the values of operands to produce logical value in C language

a)

Logical operator

b)

Relational operator

c)

Assignment operator

d)

None of the above

47.

An opertor used to check a condition and select a value depending on the value of the condition is called

a)

Logical operator

b)

Decrement operator

c)

Conditional or Ternary operator

d)

Bitwise operator

48.

Which operators perform operations on data in binary level?

a)

Logical operator

b)

Bitwise operator

c)

Additional opertors

d)

None of the above

49.
How will you print \n on the screen?
a)
printf("\n");
b)
echo "\\n";
c)
printf('\n');
d)
printf("\\n");
50.

What is the value of this expression using integer arithmetic:

7 / 4

a)

1

b)

2

c)

1.75

51.

Determine the value of this expression using integer arithmetic:

5 % 7

a)

0

b)

2

c)

5

52.

Determine the value of b in this code fragment:

int a=3, b;

b=++a;

a)

3

b)

4

c)

2

53.

Determine the value of the expression using integer arithmetic:

6 * 9 % 3 / 2

a)

2

b)

0

c)

18

54.

Determine the value of a in the second line of the code fragment:

int a=1, b=2;

a=b--;

a)

1

b)

0

c)

2

55.

Which line of code is correct for the statement:

Read in a value for the integer variable num.

a)

printf("%d", &num);

b)

scanf("%d", num);

c)

scanf("%d", &num);

56.

What is the EXACT output from this code fragment:

int num=10;

if(num> 7 % 3 / 2 * 3)

printf("This is True");

else

printf("This is False");

a)

This is True

b)

This is False

57.

What symbol is used in conditional operators for AND:

a)

AND

b)

&&

c)

&

58.

What will be printed on the screen from this fragment:

int num=0;

printf("%d", ++num)

a)

0

b)

1

c)

2

59.

What is the abbreviated way to write this assignment statement:

total=total+num;

a)

t=t+n;

b)

total+=num

c)

total=(total+num)

60.

C language is a

a)

structured program

b)

object oriented program

c)

oriented program

d)

basic program

61.

Relational operator

a)

+

b)

=

c)

==

d)

/

62.

a=2;b=6; (a<b):10:15

a)

10

b)

15

c)

2

d)

6

63.

After first pass the answer for x=5-6/3+8*2-1

a)

5-2+8*2-1

b)

5-6/3+16-1

c)

5-2+16-1

d)

-1/3+8*2-1

64.

%s indicates in scanf statement

a)

to get an integer

b)

to get a character

c)

to get a string

d)

to get a real no.

65.

What is the data type use for whole number?

a)

%ld

b)

%f

c)

%lf

66.

What operator that will be perform last in a given equation?

a)

+

b)

/

c)

%

67.

What format specifier is use for double data type?

a)

%lf

b)

%d

c)

%f

68.
What is an interpreter?
a)
Converts source code one instruction at a time
b)
Converts source code between 2 HLLs
c)
Converts source code between HLL and Assembly
d)
Converts keyboard presses to an ASCII code
69.
What would you use to convert high-level source code to machine code?
a)
Linker
b)
Assembler
c)
Compiler
d)
IDE
70.

Which should be the printf statement of the following program:

void main()

{

int age = 10;

printf...

}

a)

printf("I am %d years old.\n");

b)

printf("I am %f years old.\n", age);

c)

printf("I am %s years old.\n");

d)

printf("I am %d years old.\n", age);

71.

Check the following code segment and try to predict what's going to happen?

#include <stdio.h>

int main(){

int x=++2;

printf("%d",x);

return 0;

}

a)

3 will be printed on compilation and execution.

b)

2 will be printed on compilation and execution.

c)

compilation error - "Ivalue required".

d)

runtime error.

72.

Libray function getch() belongs to which header file?

a)

stdio.h

b)

conio.h

c)

stdlib.h

d)

stdlibio.h

73.

What is the value of X in the sample code given below?

X = ( 2 + 3) * 2 + 3;

a)

10

b)

13

c)

25

d)

28

74.

What value will be stored in z if the following code is executed?

x = 5 , y = -10, a = 4, b = 2;

z = x+++++y * b/a;

a)

-2

b)

0

c)

1

d)

2

75.

#include <stdio.h>

void main()

{

int k = 8;

int x = 0 == 1 && k++;

printf(“%d%d\n”, x, k);

}

a)

a) 0 9

b)

b) 0 8

c)

c) 1 9

d)

d) 1 8

76.

#include <stdio.h>

int main()

{

int x = 2, y = 2;

x /= x / y;

printf(“%d\n”, x);

return 0;

}

a)

a) 2

b)

b) 0.5

c)

c) 1

d)

d) Undefined behaviour shown

77.

#include <stdio.h>

int main()

{

int x = 2, y = 1;

x *= x + y;

printf("%d\n", x);

return 0;

}

a)

a) 6

b)

b)5

c)

c) Undefined behavior shown

d)

d) Compilation time error

78.

#include<stdio.h>

void main()

{

int a=5;

int b=6;

a++;

b++;

printf("%d %d",a,b);

}

a)

5 6

b)

6 7

c)

5 7

d)

Compilation Error

79.

#include<stdio.h>

int main()

{

int x;

for(x=-1; x<=10; x++)

{

if(x < 5)

continue;

else

break;

printf("SKCT");

}

return 0;

}

a)

A.Infinite times

b)

B. 11 times

c)

C. 0 times

d)

D.10 times

80.

#include<stdio.h>

int main()

{

int i=0;

for(; i<=5; i++);

printf("%d", i);

return 0;

}

a)

Compilation Error

b)

6

c)

012345

d)

12345

81.

#include<stdio.h>

int main()

{

float a = 0.7;

if(0.7 > a)

printf("Hi\n");

else

printf("Hello\n");

return 0;

}

a)

A.Hi

b)

B. Hello

c)

C. Hi Hello

d)

D.None of above

82.

#include<stdio.h>

int main()

{

int k, num = 30;

k = (num < 10) ? 100 : 200;

printf("%d\n", num);

return 0;

}

a)

A.200

b)

B. 30

c)

C. 100

d)

D.500

83.

#include<stdio.h>

int main()

{

int a = 300, b, c;

if(a >= 400)

b = 300;

c = 200;

printf("%d, %d, %d\n", a, b, c);

return 0;

}

a)

A.300, 300, 200

b)

B. Garbage, 300, 200

c)

C. 300, Garbage, 200

d)

D.300, 300, Garbage

84.

#include<stdio.h>

int main()

{

char j=1;

while(j < 5)

{

printf("%d, ", j);

j = j+1;

}

printf("\n");

return 0;

}

a)

1 2 3 ... 127

b)

1 2 3 ... 255

c)

1 2 3 ... 127 128 0 1 2 3 ... infinite times

d)

1, 2, 3, 4

85.

The modulus operator cannot be used with a long double.

a)

True

b)

False

86.

What is right way to Initialize array?

a)

int num[6] = { 2, 4, 12, 5, 45, 5 };

b)

int n{} = { 2, 4, 12, 5, 45, 5 };

c)

int n{6} = { 2, 4, 12 };

d)

int n(6) = { 2, 4, 12, 5, 45, 5 };

87.

An array elements are always stored in ________ memory locations.

a)

sequential

b)

Random

c)

Sequential and Random

d)

None of the above

88.

what will be printed after Execution of the following program

void main()

{

int a[5]={11,13,56,20,5};

printf("%d",a[2]);

}

a)

garbage value

b)

13

c)

56

d)

20

89.

if two strings are identical then function strcmp() returns

a)

0

b)

-1

c)

true

d)

none of these

90.

what will be the output of the program?

#include <stdio.h>

#include<string .h>

void main()

{

char str1[20]="Hello",str2="world";

strcat(str1,str2);

puts(str1);

return 0;

}

a)

Hello

b)

world

c)

Helloworld

d)

none of the above

91.

8.Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?

a)

arr[6]

b)

arr[7]

c)

arr{6}

d)

arr{7}

92.

What is a String in C Language.?

a)

String is a new Data Type in C

b)

String is an array of Characters with null character as the last element of array.

c)

String is an array of Characters with null character as the first element of array

d)

String is an array of Integers with 0 as the last element of array

93.

An array Index starts with.?

a)

-1

b)

0

c)

1

d)

2

94.

What is the minimum and maximum Indexes of this below array.?

int main()

{

int ary[9];

return 0;

}

a)

-1, 8

b)

0, 8

c)

1,9

d)

None of the above

95.

What is the output of this program

#include <stdio.h>

int main()

{ int a[2][] = { {1,1,1},{2,2,2}};

printf("%d", a[1][1]);

}

a)

1

b)

Error

c)

2

d)

0

96.

Which is output function in C

a)

int

b)

%d

c)

scanf()

d)

printf()

97.

Which one is input function in C

a)

printf()

b)

scanf()

c)

int

d)

%d

98.

syntax of scanf() in C

a)

scanf("format specifier",variable);

b)

scanf("format specifier",&variable);

c)

scanf("format specifier,variable");

d)

scanf(format specifier,&"variable");

99.

syntax of scanf() in C

a)

scanf("format specifier",variable);

b)

scanf("format specifier",&variable);

c)

scanf("format specifier,variable");

d)

scanf(format specifier,&"variable");

100.

syntax of printf() in C

a)

printf("%format specifier",&variable);

b)

printf("%format specifier",variable);

c)

'printf(%format specifier,"variable");

d)

printf("%format specifier,&variable");