Font size
WorksheetsQuality Assessment - 20CS1001 Programming for Problem Solving
Total questions: 100
Worksheet time: 1hrs 21mins
In the following loop construct, which one is executed only once always.
for(exp1; exp2; exp3)
exp1
exp3
exp1 and exp3
exp1,exp2 and exp3
The continue statment cannot be used with
for
while
do while
switch
goto can be used to jump from main to within a function?
true
false
-
-
Which loop is guaranteed to execute at least one time.
for
while
do while
none of the above
A labeled statement consist of an identifier followed by
:
;
?
=
c = (n) ? a : b; can be rewritten asexp1 ? exp2 : exp3;
if(n){c = a;}else{c = b;}
if(!n){c = a;}else{c = b;}
if(n){c = b;}else{c = a;}
None of the above
What will be the output of the following C code?
#include <stdio.h>
int main()
{
while ()
printf("In while loop ");
printf("After loop\n");
}
In while loop after loop
After loop
Compile time error
Infinite loop
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");
}
In while loop
In while loop after loop
After loop
Infinite loop
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);
}
In while loop
In while loop
In while loop
In while loop
In while loop
Depends on the compiler
Compile time error
#include <stdio.h>
int main()
{
int i = 0;
do {
i++;
printf("in while loop\n");
} while (i < 3);
}
2
3
4
1
#include <stdio.h>
int main()
{
int i = 0;
while (i < 3)
{
i++;
printf("In while loop\n");
}
}
2
3
4
1
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 0;
do
{
printf("Hello");
} while (i != 0);
}
Nothing
H is printed infinite times
Hello
Run time error
#include<stdio.h>
int main()
{
int i;
for(i=0;i<10;i++);
printf("%d ",i);
}
0 1 2 3 4 5 6 7 8 9
Compile Error
Run Time Error
10
Is it possible to run program without main() function?
yes
no
-
-
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);
}
55
54
1
0
int main()
{
int a = 10, b = 25;
a = b++ + a++;
b = ++b + ++a;
printf("%d %d n", a, b);
}
36 64
35 62
36 63
30 28
#include<stdio.h>
int main()
{
float a=0.7;
if(a<0.7)
{
printf("C");
}
else
{
printf("C++");
}
}
C
C++
Compilation Error
None of the these
int main() {
int m = -10, n = 20;
n = (m < 0) ? 0 : 1;
printf("%d %d", m, n);
}
-10 0
10 20
20 -10
0 1
#include<stdio.h>
int main()
{
int a=2,b=7,c=10;
c=a==b;
printf("%d",c);
}
0
7
2
Compilation error
What is the output of C Program.?
int main()
{
int a=5;
while(a >= 3);
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
GREEN
RABBIT GREEN
RABBIT is printed infinite times
None of the above
What is the output of C Program.?
int main()
{
int a=25;
while(a <= 27)
{
printf("%d ", a);
a++;
}
return 0;
}
25 25 25
25 26 27
27 27 27
Compiler error
What is the output of C Program.?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
}
while(a <= 30);
return 0;
}
32
33
30
No Output
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;
}
No Output
32 33 34
32 33 34 35
Compiler error
Choose a correct C Statement.
a++ is (a=a+1) POST INCREMENT Operator
a-- is (a=a-1) POST DECREMENT Operator
--a is (a=a-1) PRE DECREMENT Operator
++a is (a=a+1) PRE INCREMENT Operator
All the above.
What is the output of C Program.?
int main()
{
int k;
for(;;)
{
printf("TESTING\n");
break;
}
return 0;
}
No Output
TESTING
Compiler error
None of the above
What is the way to suddenly come out of or Quit any Loop in C Language.?
continue; statement
break; statement
leave; statement
quit; statement
Choose correct C while loop syntax.
while(condition) { //statements }
{ //statements }while(condition)
while(condition); { //statements }
while() { if(condition) { //statements } }
Choose a correct C for loop syntax.
for(initalization; condition; incrementoperation) { //statements }
for(declaration; condition; incrementoperation) { //statements }
for(declaration; incrementoperation; condition) { //statements }
for(initalization; condition; incrementoperation;) { //statements }
What is the output of C Program.?
int main()
{
int a=5;
while(a==5)
{
printf("RABBIT");
break;
}
return 0;
}
RABBIT is printed unlimited number of times
RABBIT
Compiler error
None of the above.
What is the output of C Program.?
int main()
{
int a=5;
while(a=123)
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
GREEN
RABBIT GREEN
RABBIT is printed unlimited number of times.
Compiler error.
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);
}
In while loop
In while loop
In while loop
In while loop
In while loop
Depends on the compiler
Compile time error
1.Relational
2.Arithmetic
3.Logical
4.Assignment
Every C Program Statement must be terminated with a
.
#
;
!
What does the following code fragment write to the monitor?
Under
Over
Under the limit
Over the limit
What does the following code fragment write to the monitor?
Under
Over
Under the limit
Over the limit
Evaluate(to true or false) each of the following expressions:
(1) 14 <= 14
(2) 14 < 14
false false
true true
true false
false true
When applied to a variable, what does the unary "&" operator yield?
The variable's address
The variable's right value
The variable's binary form
The variable's value
The operator "&" is used for
Bitwise AND
Bitwise OR
Logical AND
Logical OR
The operator "&" is used for
Bitwise AND
Bitwise OR
Logical AND
Logical OR
The size of a character variable in C is
8 bytes
4 bytes
2 bytes
1 byte
The words if, else, auto, float etc. have predefined meaning and users cannot use them as variables.
These words are called
keywords
identifier
data types
constant
Which operators are used to compare the values of operands to produce logical value in C language
Logical operator
Relational operator
Assignment operator
None of the above
An opertor used to check a condition and select a value depending on the value of the condition is called
Logical operator
Decrement operator
Conditional or Ternary operator
Bitwise operator
Which operators perform operations on data in binary level?
Logical operator
Bitwise operator
Additional opertors
None of the above
What is the value of this expression using integer arithmetic:
7 / 4
1
2
1.75
Determine the value of this expression using integer arithmetic:
5 % 7
0
2
5
Determine the value of b in this code fragment:
int a=3, b;
b=++a;
3
4
2
Determine the value of the expression using integer arithmetic:
6 * 9 % 3 / 2
2
0
18
Determine the value of a in the second line of the code fragment:
int a=1, b=2;
a=b--;
1
0
2
Which line of code is correct for the statement:
Read in a value for the integer variable num.
printf("%d", &num);
scanf("%d", num);
scanf("%d", &num);
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");
This is True
This is False
What symbol is used in conditional operators for AND:
AND
&&
&
What will be printed on the screen from this fragment:
int num=0;
printf("%d", ++num)
0
1
2
What is the abbreviated way to write this assignment statement:
total=total+num;
t=t+n;
total+=num
total=(total+num)
C language is a
structured program
object oriented program
oriented program
basic program
Relational operator
+
=
==
/
a=2;b=6; (a<b):10:15
10
15
2
6
After first pass the answer for x=5-6/3+8*2-1
5-2+8*2-1
5-6/3+16-1
5-2+16-1
-1/3+8*2-1
%s indicates in scanf statement
to get an integer
to get a character
to get a string
to get a real no.
What is the data type use for whole number?
%ld
%f
%lf
What operator that will be perform last in a given equation?
+
/
%
What format specifier is use for double data type?
%lf
%d
%f
Which should be the printf statement of the following program:
void main()
{
int age = 10;
printf...
}
printf("I am %d years old.\n");
printf("I am %f years old.\n", age);
printf("I am %s years old.\n");
printf("I am %d years old.\n", age);
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;
}
3 will be printed on compilation and execution.
2 will be printed on compilation and execution.
compilation error - "Ivalue required".
runtime error.
Libray function getch() belongs to which header file?
stdio.h
conio.h
stdlib.h
stdlibio.h
What is the value of X in the sample code given below?
X = ( 2 + 3) * 2 + 3;
10
13
25
28
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;
-2
0
1
2
#include <stdio.h>
void main()
{
int k = 8;
int x = 0 == 1 && k++;
printf(“%d%d\n”, x, k);
}
a) 0 9
b) 0 8
c) 1 9
d) 1 8
#include <stdio.h>
int main()
{
int x = 2, y = 2;
x /= x / y;
printf(“%d\n”, x);
return 0;
}
a) 2
b) 0.5
c) 1
d) Undefined behaviour shown
#include <stdio.h>
int main()
{
int x = 2, y = 1;
x *= x + y;
printf("%d\n", x);
return 0;
}
a) 6
b)5
c) Undefined behavior shown
d) Compilation time error
#include<stdio.h>
void main()
{
int a=5;
int b=6;
a++;
b++;
printf("%d %d",a,b);
}
5 6
6 7
5 7
Compilation Error
#include<stdio.h>
int main()
{
int x;
for(x=-1; x<=10; x++)
{
if(x < 5)
continue;
else
break;
printf("SKCT");
}
return 0;
}
A.Infinite times
B. 11 times
C. 0 times
D.10 times
#include<stdio.h>
int main()
{
int i=0;
for(; i<=5; i++);
printf("%d", i);
return 0;
}
Compilation Error
6
012345
12345
#include<stdio.h>
int main()
{
float a = 0.7;
if(0.7 > a)
printf("Hi\n");
else
printf("Hello\n");
return 0;
}
A.Hi
B. Hello
C. Hi Hello
D.None of above
#include<stdio.h>
int main()
{
int k, num = 30;
k = (num < 10) ? 100 : 200;
printf("%d\n", num);
return 0;
}
A.200
B. 30
C. 100
D.500
#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.300, 300, 200
B. Garbage, 300, 200
C. 300, Garbage, 200
D.300, 300, Garbage
#include<stdio.h>
int main()
{
char j=1;
while(j < 5)
{
printf("%d, ", j);
j = j+1;
}
printf("\n");
return 0;
}
1 2 3 ... 127
1 2 3 ... 255
1 2 3 ... 127 128 0 1 2 3 ... infinite times
1, 2, 3, 4
The modulus operator cannot be used with a long double.
True
False
What is right way to Initialize array?
int num[6] = { 2, 4, 12, 5, 45, 5 };
int n{} = { 2, 4, 12, 5, 45, 5 };
int n{6} = { 2, 4, 12 };
int n(6) = { 2, 4, 12, 5, 45, 5 };
An array elements are always stored in ________ memory locations.
sequential
Random
Sequential and Random
None of the above
what will be printed after Execution of the following program
void main()
{
int a[5]={11,13,56,20,5};
printf("%d",a[2]);
}
garbage value
13
56
20
if two strings are identical then function strcmp() returns
0
-1
true
none of these
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;
}
Hello
world
Helloworld
none of the above
8.Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?
arr[6]
arr[7]
arr{6}
arr{7}
What is a String in C Language.?
String is a new Data Type in C
String is an array of Characters with null character as the last element of array.
String is an array of Characters with null character as the first element of array
String is an array of Integers with 0 as the last element of array
An array Index starts with.?
-1
0
1
2
What is the minimum and maximum Indexes of this below array.?
int main()
{
int ary[9];
return 0;
}
-1, 8
0, 8
1,9
None of the above
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]);
}
1
Error
2
0
Which is output function in C
int
%d
scanf()
printf()
Which one is input function in C
printf()
scanf()
int
%d
syntax of scanf() in C
scanf("format specifier",variable);
scanf("format specifier",&variable);
scanf("format specifier,variable");
scanf(format specifier,&"variable");
syntax of scanf() in C
scanf("format specifier",variable);
scanf("format specifier",&variable);
scanf("format specifier,variable");
scanf(format specifier,&"variable");
syntax of printf() in C
printf("%format specifier",&variable);
printf("%format specifier",variable);
'printf(%format specifier,"variable");
printf("%format specifier,&variable");
