100% found this document useful (2 votes)
351 views7 pages

Acumen 01

The document contains a set of questions related to C programming. It covers topics like file handling, operators, data types, structures, pointers, macros and variable argument functions. The output of sample code snippets is also tested by some questions.

Uploaded by

ratulray2006
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
351 views7 pages

Acumen 01

The document contains a set of questions related to C programming. It covers topics like file handling, operators, data types, structures, pointers, macros and variable argument functions. The output of sample code snippets is also tested by some questions.

Uploaded by

ratulray2006
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

ACUMEN 2001

Deep Blue Sea Prelims

1. When a program is started, the files that is/are opened


automatically :
a) stdin
b) stderr
c) stdin, stdout and stderr
d) None

2. When following code is executed for input 12b12


main()
{
int x,y;
scanf("%d %*c %d",&x,&y);
printf("%d %d",x,y);
}
a) compilation error.
b) garbage values.
c) 12 12
d) none of these.

3. char *x = "car";

Given the definition for x above, which one of the following


will NOT print the letter r?

a) printf( "%c\n", *x + 2 );
b) printf( "%c\n", (&x)[0][2] );
c) printf( "%c\n", 2[x] );
d) printf( "%c\n", x[2] );
e) printf( "%c\n", *( x + 2 ) );

4. Maximum memory allocated by malloc is ____________?

5. As far as the operators + and , are concerned, which one is true?


a) , is not an operator, + always is an operator
b) + can act as a separator, , is always an operator
c) , can act as a separator as well an operator
d) + can act as a separator as well an operator

Give Output For following questions :

6. void main()
{
printf("%s%c%c%c%c",&7["TREADING"],1["TREADING"],2["TREADING"],
3["TREADING"],"TREADING"[0]);
}
a) INDIA b) TREADING c) GREAT d) Compilation error

7. #include <stdio.h>
void myFunc (int x) ;
void myFunc (int x)
{
if (x > 0)
myFunc(--x);
printf("%d ", x);
}
int main()
{
myFunc(5);
return 0;
}
a) 0 0 1 2 3 4 b) 0 1 2 3 4 5 c) 0 1 2 3 4 d) 1 2 3 4 5
8 main()
{
printf("MCA-CIC"+4);
printf(4+"\nMCA-CIC");
}
output :________________________________________ ?

9.
main()
{ char *p="ay9m";
char c;
clrscr();
c=++*p++;
printf("%c %s",c,p);
}
output :________________________________________ ?

10.
main()
{
int i=97;
switch(i)
{
case 'a' : if(i<3)
case 'b' : i=10;i=11;
printf("%d",i);
}
}

a) 3 b) 11 c) 10 d) 97

11.
struct { int a[3],b;} w[]={{1,2,3},2};
int main()
{
printf("w[0].b=%d\n",w[0].b);
return 0;
}

a) 0 b) 1 c) 2 d) 3

12.
struct tmp{
unsigned dg : 3;
unsigned fg : 5;
unsigned zg : 1;
unsigned xg : 5;
unsigned cg : 1;
}e;

main()
{
e.dg=1; e.fg=0;
printf("%d,%d",e.dg,e.fg);
printf("\n%d",sizeof(e));

a) 1 b) 2 c) 3 d) 4
.pa
13. main()
{
int z = 0;
int y;
for(y=1; y++ < 8; )
z += y;
printf("z=%d\n", z);
}
a) z=8 b) z=9 c) z=27 d) z=35

14. main()
{
int x = 1;
if (x = 15 % 5)
printf("x=3\n");
else
printf("x=5\n");
}

a) x=0 b) x=1 c) x=3 d) x=5

15. main()
{
int i=2,j=3,k;
k=i+++j;
printf("%d %d %d",i,j,k);
}
output :________________________________________ ?

16.
main()
{
char a=2;
printf("%d",(2^3)+(a^a));
}

a) error b) garbage value c) 0 d) 1

17.
main()
{
char far *far *ptr;
printf("%d,%d,%d",sizeof(ptr),sizeof(*ptr),sizeof(**ptr));
}

output :________________________________________ ?

18.
main()
{
printf("%d,%d,%d",5,!5,!!5);
printf("\n%d,%d,%d",5,~5,~~5);
}
output :________________________________________ ?

19.
#define scanf "%s is a string"
main()
{
printf(scanf,scanf);
}

output :________________________________________ ?
.pa
20. main()
{
char a[10]="\\0\0\2bc";
int i=0;
while(i<3)
{
switch(a[i++])
{
case '\\' :
printf("\nThis question is good");
break;
case 0 :
printf("\nThis question is too good");
break;
default :
printf("\nPredict the output");
}
}
}
Give output ?

21. main()
{
struct Data {
int a;
int b;
} y[4] = { 1, 10, 3, 30, 2, 20, 4, 40};

struct Data *x = y;
int i;

for(i=0; i<4; i++) {


x->a = x->b, ++x++->b;
printf("%d %d\t", y[i].a, y[i].b);
}
}
output :________________________________________ ?

22.
#define PRINTX printf("\n%d",x)
main()
{
int x=2,y,z;
x*=3 + 2; PRINTX;
x*= y = z = 4; PRINTX;
x = y+1 == z; PRINTX;
x == ( y = z ); PRINTX;
}
output :________________________________________ ?

23. main()
{
int a;
a = (1,45,012)>=12?100:200;
printf(" %d",a);
a = 1,2,24<=12?100:200;
printf(" %d",a);
a = (1,2,30);
printf(" %d",a);
}

output :________________________________________ ?
.pa
24.
main()
{
struct
{
int a: 1;
int b: 2;
}t;
t.b=6;
t.a=2;
printf("%d %d",t.a,t.b);
}
output :________________________________________ ?

25.
funct(char* str)
{
printf("%s\n",str);
}
main()
{
static int ii = 1;
int jj = 2;
ii+=++jj;
funct(ii+++"RECT MCA");
}
output :________________________________________ ?

26. main()
{
int i=6,j=4;
printf("NO\n");
switch(i)
{
case 1: do{ printf("yes\n");
case 2:
case 3:
case 4:
case 5:
case 6: j--;
}while (j);
}
}
Give Output ?

27.what do the following declaration signify ?


a.) void (*p)(void (*)(int *, void **),int (*) (void **,int *));

b.) int *( *( *( *x)( )[ ] ) )( ) ;

28. Can you suggest any other way of writing following expression such that 30 is
used only once ?

a<=20? b=30:(c=30);

29.)
# define DEF "CigMA"
# define DEFI "\"\at\0rect"
main ( )
{
printf(DEF DEFI);
}

output :________________________________________ ?

30.
Suppose the file is saved as var.c and if we pass a b c as the command
line arguments, predict the output:

#include "stdarg.h"
int main(int ar,char *ar1[])
{
display(ar,*ar1[1],*ar1[2],*ar1[3]);
}
display(int num,...)
{
char c;int j;
va_list ptr;
va_start(ptr,num);
for (j=1;j<num;j++)
{
c=va_arg(ptr,int);
printf("%c",c);
}
va_end(ptr);
}######

You might also like