Question 1
The following three 'C' language statements is equivalent to which single statement? y=y+1; z=x+y; x=x+1
z = x + y + 2;
z = (x++) + (++y);
z = (x++) + (y++);
z = (x++) + (++y) + 1;
Question 2
Output of following C code will be?
#include <stdio.h>
int main()
{
int a = 0;
int b;
a = (a == (a == 1));
printf("%d", a);
return 0;
}
0
1
Big negative number
-1
Question 3
Output of following C code will be?
#include <stdio.h>
#include <stdlib.h>
int top = 0;
char fun1()
{
char a[] = {'a', 'b', 'c', '(', 'd'};
return a[top++];
}
int main()
{
char b[10];
char ch2;
int i = 0;
while ((ch2 = fun1()) != '(')
{
b[i++] = ch2;
}
b[i] = '\0'; // Add null-terminating character to mark the end of the string
printf("%s", b);
return 0;
}
abc(
abc
3 special characters with ASCII value 1
Empty String
Question 4
In the context of modulo operation (i.e. remainder on division) for floating point (say 2.1 and 1.1), pick the best statement.
For floating point, modulo operation isn't defined and that's why modulo can't be found.
(2.1 % 1.1) is the result of modulo operation.
fmod(2.1,1.1) is the result of module operation.
((int)2.1) % ((int)1.1) is the result of modulo operation.
Question 5
Question 6
Question 7
The below program would give compile error because comma has been used after foo(). Instead, semi-colon should be used i.e. the way it has been used after bar(). That's why if we use semi-colon after foo(), the program would compile and run successfully while printing "GeeksQuiz"
#include <stdio.h>
void foo(void)
{
printf("Geeks");
}
void bar(void)
{
printf("Quiz");
}
int main()
{
foo(), bar();
return 0;
}
TRUE
FALSE
Question 8
What does the following program do when the input is unsigned 16-bit integer?
#include
main( )
{
unsigned int num;
int i;
scanf (“%u”, &num);
for ( i = 0; i<16; i++)
{
printf (“%d”, (num << i & 1 << 15 ) ? 1:0);
}
}
It prints all even bits from num
It prints all odd bits from num
It prints binary equivalent of num
None of the above
Question 9
Question 10
Write the output of the following C program
#include <stdio.h>
int main (void)
{
int shifty;
shifty = 0570;
shifty = shifty >>4;
shifty = shifty <<6;
printf("the value of shifty is %o",shifty);
}
the value of shifty is 15c0
the value of shifty is 4300
the value of shifty is 5700
the value of shifty is 2700
There are 45 questions to complete.