Sei sulla pagina 1di 4

Q. Linker generates ___ file.

Q. Compiler generates _____ file.

Q. What is the output of the below code snippet.


#include<stdio.h>
main()
{
printf("%d", -11%2);
}
A - 1
B - -1
C - 5.5
D - -5.5

Q. What is the output of the following program?


#include<stdio.h>

main()
{
int x = 1;

do
printf("%d ", x);
while(x++<=1);
}
A - 1
B - 1 2
C - No output
D - Compile error

Q. Which of the following variable cannot be used by switch-case statement? float.

Q. What value strcmp() function returns when two strings are the same? 0.

Q. If, the given below code finds the length of the string then what will be the
length?
#include<stdio.h>

int xstrlen(char *s)


{
int length = 0;

while(*s!='\0')
{length++; s++;}
return (length);
}
int main()
{
char d[] = "IndiaMAX";

printf("Length = %d\n", xstrlen(d));


return 0;
}
A - Code returns error
B - Code returns the length 8
C - Code returns the length 6
D - Code returns the length 2
Q. What is the output of the following code snippet?
#include<stdio.h>

main()
{
int x = 5;

if(x=5)
{
if(x=5) break;
printf("Hello");
}
printf("Hi");
}
A - Compile error
B - Hi
C - HelloHi
D - Compiler warning

Q. What will happen if in a C program you assign a value to an array element whose
subscript exceeds the size of array?
the program crashes.

Q. In C, if you pass an array as an argument to a function, what actually gets


passed?
base address.

Q. Predict the output of the following C snippets

int main()
{
int main = 56;
printf("%d", main);
return 0;
}
a) Compiler Error
b) Depends on the compiler
c) 56
d) none of above

Q. What is the output of the below c code?

#include<stdio.h>
int main()
{
char ch;
if(ch = printf(""))
printf("It matters\n");
else
printf("It doesn't matters\n");
return 0;
}
a) It matters
b) It doesn’t matters
c) Run time error
d) Nothing

Q. Predict the output of the following C snippets?


view source

print
?
int main()
{
char *g = NULL;
char *h = 0;
if (g)
printf(" g ");
else
printf("nullg");
if (h)
printf("h\n");
else
printf(" nullh\n");
}
a) nullg nullh
b) Depends on the compiler
c) g nullh
d) g h

Q.
What will be the output of the program?
#include<stdio.h>
int sumdig(int);
int main()
{
int a, b;
a = sumdig(123);
b = sumdig(123);
printf("%d, %d\n", a, b);
return 0;
}
int sumdig(int n)
{
int s, d;
if(n!=0)
{
d = n%10;
n = n/10;
s = d+sumdig(n);
}
else
return 0;
return s;
}

A.
4, 4

B.
3, 3

C.
6, 6
D.
12, 12

Potrebbero piacerti anche