C Aptitude Questions
C Aptitude Questions
5+3*2%10-8*6
a) -42
b) -37
c) -28
d) -32
a) 10
b) 10 10
c) Error
d) None of these
printf("%X%x%ci%x",11,10,'s',12);
a) error
b) Bas94c
c) basc
d) none of these
a) 0
b) 1
c) error
d) garbage value
Q 5. Output of the given statements-
a) 1
b) 2
c) 3
d) infinite number of times
a) 000
b) 210
c) 021
d) 02%D
printf( 3 + "goodbye");
a) dbye
b) odbye
c) bye
d) goodbye
printf("%ld", a);
a) error
b) 2
c) 0
d) garbage value
Q9. Output of the following program-
#include
void main()
{
int a = 2;
switch(a)
{
case 1:
printf("goodbye"); break;
case 2:
continue;
case 3:
printf("bye");
}
}
a) bye
b) goodbye
c) byegoodbye
d) error
int i = 1, j;
j=i----2;
printf("%d", j);
a) 2
b) -3
c) 3
d) error
#include
main()
{
int x, y = 10;
x = y * NULL;
printf("%d", x);
}
a) 10
b) 0
c) error
d) garbage value
Q12. Mark the output of following statement-
a) 29
b) 18
c) 88
d) 19
void main()
{
int a=10, b=20;
char x=1, y=0;
if(a, b, x, y)
{
printf("MONK");
}
}
a) MONK
b) ONK
c) Compilation Error
d) No Output
int i = 3;
printf("%d%d", i, i++);
a) 34
b) 44
c) 43
d) 33
a) 1.5
b) 1
c) No output
d) Error
Q16. The three standard files which can be accessed by any program in C language are-
d) All of above
e) None of above
a) Evaluated first
b) is most important
c) is fastest
d) Operates on the largest number
a) ,
b) ;
c) :
d) .
a) Arithmetic operators
b) Logical operators
c) Equality operators
d) Relational operators
Q22. Give the output of following C language code-
#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>
void main()
{
1 < 2 ? return 1: return 2;
}
a) returns 1
b) Varies
c) returns 2
#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 behaviour shown
d) Compilation time error
Q25. Give the output of following C language code-
#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
main()
{
char *p;
int *q;
long *r;
p=q=r=0;
p++;
q++;
r++;
printf("%p...%p...%p", p, q, r);
}
main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++)
{
printf(" %d ",*c);
++q;
}
for(j=0;j<5;j++)
{
printf(" %d ",*p);
++p;
}
}
main()
{
extern int i;
i=20;
printf("%d",i);
}
void main()
{
int const * p=5;
printf("%d",++(*p));
}
main()
{
int c=- -2;
printf("c=%d",c);
}
main()
{
int c=- -2;
printf("c=%d",c);
}
main()
{
int i=10;
i=!i>14;
Printf ("i=%d", i);
}
Q33. Give the output of following C language code-
#include <stdio.h>
#define a 10
main()
{
#define a 50
printf("%d",a);
}
main()
{
clrscr();
}
clrscr();
main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
}
main( )
{
int a[2][3][2] = {{{2,4}, {7,8}, {3,4}},{{2,2},{2,3},{3,4}}};
printf(“%u %u %u %d \n”, a, *a, **a, ***a);
printf(“%u %u %u %d \n”, a+1, *a+1, **a+1, ***a+1);
}
Q38. Give the output of following C language code-
main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n", i, +i);
}
Q39. State the files which automatically opened whenever a C file is executed?
main()
{
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));
}
#define FALSE -1
#define TRUE 1
#define NULL 0
main()
{
if(NULL)
puts("NULL");
else if(FALSE)
puts("TRUE");
else
puts("FALSE");
}
main()
{
int k=1;
printf("%d==1 is ""%s", k, k==1?"TRUE":"FALSE");
}
Q43. Give the output of following C language code-
main()
{
int *j;
{
int i=10;
j=&i;
}
printf("%d",*j);
}
#include<stdio.h>
main()
{
register i=5;
char j[]= "hello";
printf("%s %d",j,i);
}
main()
{
int i=_l_abc(10);
printf("%d\n",--i);
}
int _l_abc(int i)
{
return(i++);
}