Worksheetsc programming
Total questions: 30
Worksheet time: 15mins
What is the 16-bit compiler allowable range for integer constants?
-3.4e38 to 3.4e38
-32767 to 32768
-32668 to 32667
-32768 to 32767
Directives are translated by the
Pre-processor
Compiler
Linker
Editor
What is the result after execution of the following code if a is 10, b is 5, and c is 10?
if ((a > b) && (a <= c))
a = a + 1;
else
c = c+1;
a = 10, c = 10
a = 11, c = 10
a = 10, c = 11
a = 11, c = 11
What will happen when the following code is executed?
void main()
{
printf("MIET");
main();
}
Wrong statement
It will keep on printing MIET
It will print MIET once
None of these
What will the result of num1 variable after execution of the following statements?
int j = 1, num1 = 4;
while (++j <= 10)
{
num1++;
}
11
12
13
14
What will be the output of the following code?
#include <stdio.h>
int main()
{
int *ptr, a = 10;
ptr = &a;
*ptr += 1;
printf("%d,%d/n", *ptr, a);
}
10, 10
10, 11
11, 10
11, 11
Give the following declarations and an assignment statement. Which one is equivalent to the expression str [4]?
char str[80];
char * p;
p = str;
p + 4
*p + 4
*(p + 4)
p[3]
Find the output in following code
int main ()
{
int a,b ;
a= b= 4 ;
b =a++;
Printf ( " %d %d %d %d", a++, --b, ++a, b--);
}
5 3 73
5 4 5 3
6 2 6 4
Syntax Error
Find error/ output in following code
How many times " placement Questions" will print.
int main
{
int x;
for ( x=1;x <=10; x++)
{
if ( x < 5)
Continue;
else
break;
Printf (" placement Question ");
{
return 0;
}
Infinite time
11 times
0 time
10 times
Find error/ output in following code
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
Find error/output in following code
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
Find error/ output in following code
int main ()
{
int i = 0;
for ( ; ;)
printf ( "%d", i) ;
return 0;
}
O times
Infinite times
10 times
1 times
Find Error/ output in following code
Void main ()
{
int a= 1, b= 2, c = 3;
Char d = 0;
if (a,b,c,d)
{
printf ( " EXAM") ;
}
}
No output and No error
EXAM
Runtime Error
Compile time error
select the correct syntax to read a variable named num of type integer from user
scanf("%d",num);
scanf("%d",&num);
scanf("%d,&num");
scanf("%d,num");
Which of the following is not logical operator?
&
||
!
&&
#include <stdio.h>
int main(){
int x= 5%2 *3/2;
printf("%d",x);
return 0;
}
1
2
3
99
What is the Output:
int a=5;
printf("%d", ++a);
5
6
7
4
What is the Output :
void main()
{
int a=5,b=6,k;
k=b>a?b:a;
printf("%d",k);
}
5
6
11
Error
There are ___ storage classes in C
2
4
6
8
Programming Language C has only --------- Keywords
32
31
33
34
1 GB is equal to ------------
1024KB
1024 Byte
1024MB
1024 nano
The correct order of evaluation for the expression “z = x + y * z / 4 % 2 – 1”
* / % = + -
/ * % - + =
- + = * % /
* / % + - =
A pointer pointing to a memory location of the variable even after deletion of the variable is known as _____
far pointer
dangling pointer
null pointer
void pointer
What is the output of this statement "printf("%d", (a++))"?
The value of (a + 1)
The current value of a
Error message
Garbage
The user can also write one or more statements in one line by separating semicolon (;)
True
False
2. Which statement best describes logic errors?
An error in a program that causes it to produce incorrect ouputs but not a crash.
An error in a program that causes it to crash.
An error in the program caused by mis-spelt instructions.
An error in a program caused by hardware failure.
12.Is it possible to return two values by any function?
yes
no
14.what will be the output?
#include <stdio.h>
void decrement();
int main()
{
decrement();
decrement();
decrement();
return 0;
}
void decrement()
{
int i = 5;
printf("%d",i);
i--;
}
A) 555
(B) 543
(C) 545
(D) 544
15.Choose the correct answer.
a) Recursion is always better than iteration.
b) Recursion uses more memory compared to iteration.
c) Recursion uses less memory compared to iteration.
d) Iterative function is always better and simpler to write than recursion.
Given two literals 0x001B and 033. What are these equal to?
21 and 23
27 and 33
33 and 33
27 and 27
