Placement Papers - Caritor

Caritor Placement Paper Bangalore on 23rd June 2004 (Technical Section-C)
Posted by :
Chetan
(8)
Paper: Caritor Placement Paper Bangalore on 23rd June 2004 (Technical Section-C)
C-QUESTIONS
1. Struct x
{
int i
char c;
}
union y{
struct x a;
double d;
};
printf("%d",sizeof(union y));
a)8
b)5
c)4
d)1
ans:8
2. struct x{
char c1;
char c2;
int i;
short int j;
};
struct y{
short int j;
char c1
char c2;
int i;
}
printf("%d %d",size of (struct x),size of (struct y));
a)12 12
b)8 8
c)12 8
d)8 12
3. enum x {a=1,b,c,d,f=60,y}
printf("%d",y);
a) 5
b) 61
c) 6
d) 60
ans:b
4. #include<stdio.h>
void main()
{
int k=2,j=3,p=0;
p=(k,j,k)
printf("%d
",p);
}
a) 2
b) error
c) 0
d) 3
ans:a
5. #include<stdio.h>
void main()
{
unsigned int i= -1;
printf("%d
",i);
printf("%u
",i*-1);
}
a) runtime error
b) compilation error
c) prints -1 to 1
d) prints 1 and 1
6. How to typedef a function pointer which takes int as a parameter and return an int
a) Is not possible
b) typedef int *funcptr int;
c) typedef int * funcptr( int);
d) typedef int (*funcptr)(int);
ans:d
7. #include<stdio.h>
void main()
{
int k=10;
k<<=1;
printf("%d
",k);
}
a) 10
b) 0
c) 20
d) compilation error
ans:c
8. #include<stdio.h>
void main()
{
int a[2][2]={{2},{3}};
printf("%d",a[0][0]);
printf("%d",a[0][1]);
printf("%d",a[1][0]);
printf("%d",a[1][1]);
}
a) 2300 b)2000 c) 0030
d) 2030
ans:d
9. #include<stdio.h>
void main(int x)
{
printf("%d",x) ;
}
if the name of the executable file is abc and the command line is given as abc xy what is the output
a)compilation error
b) 1
c) 2
d) undefined
ans:2
11. #include<stdio.h>
void main(int argc)
{
int d=1234.5678;
printf("%d",d);
}
a) error, b) 1234.5678, c) 1234, d) 1235
ANS:c
12. #include<stdio.h>
void main(int argc)
{
int a[]={5,6};
printf("%d",a[1.6]);
}
a) 5, b) runtime error, c) compilation error, d) 6
ANS:d
13. #include<stdio.h>
void main(int arg c)
{
int x=1111;
printf("%d",!x);
}
a.prints 1111
b.compilation error
c.prints 0
d.is not a valid option
ans:c
14. int i=10;
a.declaration
b.definition
c.both
d.none
ans:c
15. #include<stdio.h>
void main(int arg c)
{
char a[]=abcdefghijklmnopqrstuvwxyz;
char *p=a;
printf(%d,strlen(p));
p+=10;
printf(%d,strlen(a));
}
a.26 26
b.26 16
c.compilation error
d.16 26
ans:a
16. if the following program (myprog)is run from the command line as myprog 1 2 3 what would be the output?
Main(int argc , char *argv[])
{ int I ,j=0;
for (I=0;I<argc;I++)
j=j+atoi(argv[i]);
printf(%d.j);
}
a. 123 b.6 c.error d.123
ans:6
17. what is the output of the following code?
#include<stdio.h>
void main()
{
printf("%d",printf(" hello world "));
}
a) 13, b) hello world 13, c) hello world, d) error
ANS:b
C-QUESTIONS
1. Struct x
{
int i
char c;
}
union y{
struct x a;
double d;
};
printf("%d",sizeof(union y));
a)8
b)5
c)4
d)1
ans:8
2. struct x{
char c1;
char c2;
int i;
short int j;
};
struct y{
short int j;
char c1
char c2;
int i;
}
printf("%d %d",size of (struct x),size of (struct y));
a)12 12
b)8 8
c)12 8
d)8 12
3. enum x {a=1,b,c,d,f=60,y}
printf("%d",y);
a) 5
b) 61
c) 6
d) 60
ans:b
4. #include<stdio.h>
void main()
{
int k=2,j=3,p=0;
p=(k,j,k)
printf("%d
",p);
}
a) 2
b) error
c) 0
d) 3
ans:a
5. #include<stdio.h>
void main()
{
unsigned int i= -1;
printf("%d
",i);
printf("%u
",i*-1);
}
a) runtime error
b) compilation error
c) prints -1 to 1
d) prints 1 and 1
6. How to typedef a function pointer which takes int as a parameter and return an int
a) Is not possible
b) typedef int *funcptr int;
c) typedef int * funcptr( int);
d) typedef int (*funcptr)(int);
ans:d
7. #include<stdio.h>
void main()
{
int k=10;
k<<=1;
printf("%d
",k);
}
a) 10
b) 0
c) 20
d) compilation error
ans:c
8. #include<stdio.h>
void main()
{
int a[2][2]={{2},{3}};
printf("%d",a[0][0]);
printf("%d",a[0][1]);
printf("%d",a[1][0]);
printf("%d",a[1][1]);
}
a) 2300 b)2000 c) 0030
d) 2030
ans:d
9. #include<stdio.h>
void main(int x)
{
printf("%d",x) ;
}
if the name of the executable file is abc and the command line is given as abc xy what is the output
a)compilation error
b) 1
c) 2
d) undefined
ans:2
11. #include<stdio.h>
void main(int argc)
{
int d=1234.5678;
printf("%d",d);
}
a) error, b) 1234.5678, c) 1234, d) 1235
ANS:c
12. #include<stdio.h>
void main(int argc)
{
int a[]={5,6};
printf("%d",a[1.6]);
}
a) 5, b) runtime error, c) compilation error, d) 6
ANS:d
13. #include<stdio.h>
void main(int arg c)
{
int x=1111;
printf("%d",!x);
}
a.prints 1111
b.compilation error
c.prints 0
d.is not a valid option
ans:c
14. int i=10;
a.declaration
b.definition
c.both
d.none
ans:c
15. #include<stdio.h>
void main(int arg c)
{
char a[]=abcdefghijklmnopqrstuvwxyz;
char *p=a;
printf(%d,strlen(p));
p+=10;
printf(%d,strlen(a));
}
a.26 26
b.26 16
c.compilation error
d.16 26
ans:a
16. if the following program (myprog)is run from the command line as myprog 1 2 3 what would be the output?
Main(int argc , char *argv[])
{ int I ,j=0;
for (I=0;I<argc;I++)
j=j+atoi(argv[i]);
printf(%d.j);
}
a. 123 b.6 c.error d.123
ans:6
17. what is the output of the following code?
#include<stdio.h>
void main()
{
printf("%d",printf(" hello world "));
}
a) 13, b) hello world 13, c) hello world, d) error
ANS:b
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers