C Prog
C Prog
main()
{
int x = 1;
do
printf("%d ", x);
while(x++<=1);
}
A - 1
B - 1 2
C - No output
D - Compile error
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>
while(*s!='\0')
{length++; s++;}
return (length);
}
int main()
{
char d[] = "IndiaMAX";
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.
int main()
{
int main = 56;
printf("%d", main);
return 0;
}
a) Compiler Error
b) Depends on the compiler
c) 56
d) none of above
#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
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