GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  Caritor
Go To First  |  Previous Question  |  Next Question 
 Caritor  |  Question 8 of 15    Print  
Caritor - C Questions
C QUESTIONS:
Briefcase ]

1. Struct x
{
int i;
char c;
}

union y{
struct x a;
double d;
};

printf("%d",sizeof(union y));

a)8 ans:8
b)5
c)4
d)1


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 ans:a
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
void main(){
{
# define x 10

}
printf("%d \n",++x);
}

a)11
b)10
c)compile error ans:c
d)runtime error

5. #include
void main()
{
int k=2,j=3,p=0;
p=(k,j,k);
printf("%d\n",p);

}
a)2
b)error
c)0
d)3

ans:a
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
void main()
{
int k=10;
k<<=1;
printf("%d\n",k);
}
a)10
b)0
c)20
d)compilation error ans:c

8. #include
void main()
{
int i=-10;
for(;i;printf("%d\n",i++));
}
a)error
b)prints -10 to -1
c)infinite loop
d)does not print anything
ans:b

9.
#include
void main()
{
int I=65,j=0;
for(;j<26; i++,j++){
printf("%s\n", i);
}
}
a)compilation Error
b)prints A to Z
c)prints a to z
d)runtime error
ans:b
10.
#include
void main()
{
unsigned int i=-1;
printf("%d\n",i);
printf("%u\n",i*-1);
}

a)runtime error
b)compilation error
c)prints -1 to 1
d)prints 1 and 1
ans:c
11.
#include
void main()
{
int **I;
int *j=0;
i=&j;
if (NULL != i&& NULL != *i){
printf("I am here");
}
}

a)prints I am here
b)does not print anything
c)compilaton error
d)runtime error

ans:b
12
#include
void main()
{
int *j=(int *)0x1000;
printf("%p",j);

}
a)prints-1000
b)runtime error
c)compilation error
d)none of the above

ans:d
13
#include
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

14) #include
void main(int x)

{
printf("%d",x) ;

}
if the name of the executable file is abc and the command line is
given as
abc xyz
what is the output
a)compilation error
b)1
c)2
d)undefined
ans:2

15. #include
void main(int argc)
{
char a[]={'1','2','3',0,'1','2','3'};
printf(a);
}

a) compilation error, b) 123, c) 123 123, d) 1230123
ANS:b

16. #include
void func(int *x)
{
x=(int *) malloc(sizeof(int));
printf("in func: %p\n",x);
}

void main(int argc)
{
int **pp;
int *p;
pp=(int **) malloc(sizeof(int *));
p=(int *) malloc(sizeof((int));
*pp=p;
printf("first:%p \n",*pp);
func(*pp);
printf("last %p \n",*pp);
}

assuming the p is equal to 1000 and x is equal to 2000 atfer malloc
calls

a) 1000,2000,1000, b) 1000,2000,2000, c) 1000,1000,1000 d)
2000,2000,2000
ANS:a

17. #include
#define const const
void main(int argc)
{
const int x=0;
}

a) compilation error, b) runs fine, c) runtime error, d) none
of these
ANS:b

18. #include
void main(int argc)
{
int d=1234.5678;
printf("%d",d);
}

a) error, b) 1234.5678, c) 1234, d) 1235
ANS:c

19. #include
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

20. #include
struct x
{
int i=0; /*line A*/
};
void main(int argc)
{
struct x y; /*line B*/
}

a) error due to B,
b) no problem with option A and B,
c) error somewhere other than line A and B,
d) error due to line A
ANS:d

21. #include
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
22. struct {
int len;
char *str
}*p;
++p -> len

a.increments p
b. increments len
c.compilation error
d.nothing happens with either of p and len
ans:b
23. int i=10;
a.declaration
b.definition
c.both
d.none
ans:c

24. #include
void main(int arg c)
{
char a[]=abcdefghijklmnopqrstuvwxyz;
printf(%d,sizeof(a));
}
a.25 b.26 c.27 d.28
ans:c
25. #include
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

26. if a file contains the IT solutions Inc.rn then on reading this
line the array str using fgets() what would str contain?
a. IT solutions Inc.
b. IT solutions Inc.r0
c. IT solutions Inc.rn0
d. IT solutions Inc.n0

27. 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 j=j+atoi(argv[i]);
printf(%d.j);
}

a. 123 b.6 c.error d.123
ans:6
28. when pointers declared initialized to :
a. null
b.newly allocated memory
c)nothing,its random
d)none of the above
ans:c

29. what is the output of the following code?
#include
void main()
{
printf("%d",printf(" hello world "));
}

a) 13, b) hello world 13, c) hello world, d) error
ANS:b

30. what is the output of the following code, assuming that the array
begins at location 5364875?
#include
void main()
{
int a[2][3][4]={
{2,1,4,3,6,5,8,7,0,9,2,2}
{1,2,3,4,5,6,7,8,9,0,1,2}
};
printf("%u %u %u %u",a,*a,**a,***a);
}
a) 5364875,5364876,5364877,5364878
b) 5364875,5364876,5364877,2
c) 5364875,5364875,5364876,5364876
d) 5364875,5364875,5364875,2
ANS:d

31. are null statements in c null pointers.

32. is cinst int *p same as int const* p
find similar words
beaker:chalice
formulas:constituents
time and work problem.



  
Total Answers and Comments: 5 Last Update: September 26, 2007     Asked by: IT Guy 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
November 19, 2005 20:09:17   #1  
Jyothi Shetty        

RE: Caritor - C Questions

37)size of(int)

a) always 2 bytes

b) depends on compiler that is being used

c) always 32 bits

d) can't tell

38)which one will over flow given two programs

2

prog 1: prog2:

main() main()

{ {

int fact; int fact 0

long int x; for(i 1;i< n;i++)

fact factoral(x); fact fact*i;

} }int factorial(long int x)

{

if(x>1) return(x*factorial(x-1);

}

a) program 1;

b) program 2;

c) both 1 &2

d) none

}

39) variables of fuction call are allocated in

a) registers and stack

b) registers and heap

c) stack and heap

d)

40)

avg and worst case time of sorted binary tree7) data structure used for

proority queue

a) linked list b) double linkedd list c)array d) tree

41)

main(){

char str[5] hello ;

if(str NULL) printf( string null );

else printf( string not null );

}

what is out put of the program?

a) string is null b) string is not null c) error in program d) it

executes but p

rint nothing

42)there are 0ne 5 pipe line and another 12 pipe line sates are there

and flushed

time taken to execute five instructions

a) 10 17

b) 9 16

c)25 144

d)10)

for hashing which is best on terms of buckets

a)100 b)50 c)21 d)32 ans 32

43)void f(int value){

for (i 0;i<16;i++){

if(value &0x8000>>1) printf( 1 )

else printf( 0 );

}

}

what is printed?

a) bineray value of argument b)bcd value c) hex value d) octal value

44)void f(int *p){

static val 100;

val &p;

}

main(){

int a 10;

printf( d a);

f(&a);

printf( d a);

}

what will be out put?

a)10 10

45)# define f(a b) a+b

#defiune g(c d) c*d

find valueof f(4 g(5 6))

a)26 b)51 c) d)

46)

find avg access time of cache

a)tc*h+(1-h)*tm b)tcH+tmH

c) d) tc is time to access cache tm is time to access when miss occure

47)

main()

{

char a[10] hello ;

strcpy(a '\0');

printf( s a);

}

out put of the program?

a) string is null b) string is not null c) program error d)

48)

simplyfy k map

1 x x 0

1 x 0 1

49) char a[5][15];

int b[5][15];

address of a 0x1000 and b is 0x2000 find address of a[3][4] and b[3][4]

assume char is 8 bits and int is 32 bits

50) main()

{

fork();

fork();

fork();

printf( \n hello );

}

How many times print command is executed?

51)main()

{

int i *j;

i 5;

j &i;

printf( \ni d i);

f(j);

printf( \n i d i);

}

void f(int*j)

{

int k 10;

j &k;

}

output is

a 5 10

b 10 5

c 5 5

d none

3.

some question on pipeline like you have to findout the total time

by which execution is completed for a pipeline of 5 stages.

53)

main()

{

int *s \0 ;

if(strcmp(s NULL) 0)

printf( \n s is null )p

else

printf( \n s is not null );

}

54). size of integer is

a. 2 bytes

b 4 bytes

c. machine dependant

d compiler dependent.

55).max and avg. height of sorted binary tree

a. logn n

b n logn

56). int a[5][4]

int is 2 bytes base address for array is 4000(Hexa)

what will be addr for a[3][4]?

int is 4 bytes same question.

57)

implementation of priority queue

a. tree

b linked list

c doubly linked list.

58)which of following operator can't be overloaded.

a) b)++ c)?! d)<

59)#include<iostream.h

main()

{

printf( Hello World );

}

the program prints Hello World without changing main() the o/p should

be

intialisation

Hello World

Desruct

the changes should be

a)iostream operator<<(iostream os char*s)

os<<'intialisation'<<(Hello World)<<Destruct

b) c) d)none of the above

60) term stickily bit is related to

a)kernel

b)undeletable file

c) d)none

61)semaphore variable is different from ordinary variable by

62)swap(int x y)

{

int temp;

temp x;

x y;

y temp;

}

main()

{

int x 2;y 3;

swap(x y);

}

after calling swap what are yhe values x&y?

63) static variable will be visible in

a)fn. in which they are defined

b)module

c)all the program

d)none

64)TCP/IP can work on

a)ethernet

b)tokenring

c)a&b

d)none

65)a node has the ip address 138.50.10.7 and 138.50.10.9.But it is

transmitting data from node1 to node2only. The reason may be

a)a node cannot have more than one address

b)class A should have second octet different

c)classB

d)a b c

66)for an application which exceeds 64k the memory model should be

a)medium

b)huge

c)large

d)none

67)the condition required for dead lock in unix sustem is

68)set-user-id is related to (in unix)

69)wrong statement about c++

a)code removably

b)encapsulation of data and code

c)program easy maintenance

d)program runs faster

70)struct base {int a b;

base();

int virtual function1();

}

struct derv1:base{

int b c d;

derv1()

int virtual function1();

}

struct derv2 : base

{int a e;

}

base::base()

{

a 2;b 3;

}

derv1::derv1(){

b 5;

c 10;d 11;}

base::function1()

{return(100);

}

derv1::function1()

{

return(200);

}

main()

base ba;

derv1 d1 d2;

printf( d d d1.a d1.b)

o/p is

a)a 2;b 3;

b)a 3; b 2;

c)a 5; b 10;

d)none

71) for the above program answer the following q's

main()

base da;

derv1 d1;

derv2 d2;

printf( d d d da.function1() d1.function1() d2.function1());

o/p is

a)100 200 200;

b)200 100 200;

c)200 200 100;

d)none

72)struct {

int x;

int y;

}abc;

you can not access x by the following

1)abc-- x;

2)abc[0]-- x;

abc.x;

(abc)-- x;

a)1 2 3

b)2&3

c)1&2

d)1 3 4

73) automatic variables are destroyed after fn. ends because

a)stored in swap

b)stored in stack and poped out after fn. returns

c)stored in data area

d)stored in disk

74) relation between x-application and x-server (x-win)

75)which is right in ms-windows

a)application has single qvalue system has multiple qvalue

b) multiple single

c) multiple

d)none

76)widget in x-windows is

77)gadget in x_windows is

78)variable DESTDIR in make program is accessed as

a)$(DESTDIR)

b)${DESTDIR}

c)DESTDIR

d)DESTDIR

79)the keystroke mouse entrie are interpreted in ms windows as

a)interrupt

b)message

c)event

d)none of the above

80)link between program and out side world (ms -win)

a)device driver and hardware disk

b)application and device driver

c)application and hardware device

d)none

81)dynimic scoping is

82)process dies out but still waita

a)exit

b)wakeup

c)zombie

d)steep

83)in dynamic memory allocation we use

a)doubly linked list

b)circularly linked

c)B trees

d)L trees

e)none

84)to find the key of search the data structure is

a)hask key

b)trees

c)linked lists

d)records

85)data base

--------------------------

--------------------------------

employ_code salary employ_code leave

---------------------------

----------------------------------

from to

--------------------------------------

1236 1500 1238 --- ---

1237 2000 1238 --- ---

1238 2500 1237 ---

-----

1237 --- ---

1237 --- ---

1237 --- ---

-------------------------- --------------------------------------

select employ_code employ_data leave

the number of rows in the o/p

a)18

b)6

c)7

d)3

86)which is true

a)bridge connects dissimiler LANand protocol insensitive

b)router

c)gateway

d)none of the above

87).main(argc argv)

{

if(argc<1)

printf( error );

else

exit(0);

}

If this program is compiled without giving any argument what it will

print.

88).read the folllowing code

# define MAX 100

# define MIN 100

....

....

if(x>MAX)

x 1;

else if(x<MIN)

x -1;

x 50;

if the initial value of x 200 what is the vlaue after executing this

code?

a.200

b.1

c.-1

d.50

89).a memory of 20 bytes is allocated to a string declared as char *s

then the following two statements are executed:

s Etrance

l strlen(s);

what is the value of l ?

a.20

b.8

c.9

d.21

90).given the piece of code

int a[50];

int *pa;

pa a;

to access the 6th element of the array which of the following is

incorrect?

a.*(a+5)

b.a[5]

c.pa[5]

d.*(*pa + 5)

91).consider the following structure:

struct num nam{

int no;

char name[25];

};

struct num nam

n1[] {{12 Fred } {15 Martin } {8 Peter } {11 Nicholas }};

.....

.....

printf( d d n1[2] no (*(n1 + 2) no) + 1);

What does the above statement print?

a.8 9

b.9 9

c.8 8

d.8 unpredictable value

92).identify the incorrect expression

a. a b 3 4;

b. a b c d 0;

c. float a int b 3.5;

d. int a;

float b;

a b 3.5;

92-c

93).which of the following is invalid

a. a+ b

b. a* b

c. a>> b

d. a** b

93-d

94).what is y value of the code if input x 10

y 5;

if (x 10)

else if(x 9)

else y 8;

a.9

b.8

c.6

d.5

94-d

96).a 0;

while(a<5)

printf( d\n a++);

how many times does the loop occurs?

a.infinite

b.5

c.4

d.6

96-b

97)how many times does the loop iterated ?

for (i 0;i 10;i+ 2)

printf( Hi\n );

a.10

b.2

c.5

d. infinite

97-d

98)what is incorrect among teh following

A recursive functiion

a.calls itself

b.is equivalent to a loop

c.has a termination cond

d.does not have a return value at all
 

Is this answer useful? Yes | No
March 30, 2006 08:04:02   #2  
birendra        

RE: Caritor - C Questions

hi

i want to know the answers of question

void f(int value){

for (i 0;i<16;i++){

if(value &0x8000>>1) printf( 1 )

else printf( 0 );

}


 
Is this answer useful? Yes | No
November 05, 2006 12:08:22   #3  
Deepak        

RE: Caritor - C Questions
The function should readvoid f(int value){ for(int i 0; i<16; i++) if(value &0x8000>>i) printf( 1 ); else printf( 0 );}It will print the number in binary format.
 
Is this answer useful? Yes | No
September 26, 2007 05:25:58   #4  
rahul.gupta Member Since: August 2007   Contribution: 4    

RE: Caritor - C Questions
Ans: 2 ...i think will depends on your compiler....how the padding of bytes utilise in structure...

 
Is this answer useful? Yes | No
September 26, 2007 05:34:18   #5  
rahul.gupta Member Since: August 2007   Contribution: 4    

RE: Caritor - C Questions
Ans: 4. so you are trying to increment the MACRO. which is not possible in C/C++(lang i know).substitution will happen and it will place 10 at x..so your statement will be like..
++10 which internally extends to 10 10+1 which is not possible because of lvalue which can be only a identifier....not a numerical value..

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
Related Categories
Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape