QUESTIONS
Q1.Correct
typedef struct {
char *item;
NODEPTR next;
} *NODEPTR;
Answer: struct node {
char *item;
struct node *next;
};
typedef struct node *NODEPTR
Q2 In signed magnitude what is the minimum value that can be represented with 8 bits?
a)-128
b)-255
c)-127
d)0
Q3. char *someFun1()
{
char temp[ ] = “string";
return temp;
}
char *someFun2()
{
char temp[ ] = {‘s’, ‘t’,’r’,’i’,’n’,’g’};
return temp;
}
int main()
{
puts(someFun1());
puts(someFun2());
}
a)Garbage values b)string c)Error.
Q4. #include<stdio.h>
main()
{
scanf("%d");
printf();
}
which of the following is correct?
a)compilation error
b)Run time error
c)No output
d)depends on the compiler
Q5 #include<stdio.h>
#define islower(c) ('a'<=(c) && (c)<='z')
#define toupper(c) (islower(c)?(c)-('a'-'A'):(c))
main()
{
char *p="i am fine";
while(*p)
printf("%c",toupper(*p++));
}
a)bcd
b)AFE
c)aFe
d)BCd
Q6.#include<stdio.h>
main()
{
200;
printf("tricky problem");
}
a)warning message
b)compilation error
c)run time error
d)none of these
Q7.#include<stdio.h>
main(){
int a=1,b=2,c=3;
printf("%d,%d",a,b,c);
}
a)1,2 b)2,1 c)Error d)2,3
Q8. int a[4]={1,2,3,4};
int *ptr;
ptr=a;
*(a+3)=*(++ptr)+(*ptr++);
A part of code is shown. The elements in a after
the execution of this code.
a.1 2 3 4 b. 1 2 3 6
c. compilation error d.1 2 2 4
Q9. #include<stdio.h>
proc();
main(){
int i;
for(i=0;i<2;i++)
proc();
}
proc() {
static i=10;
printf("%d",i++);
}
a)11 10 b)10,11 c)10 10 d)11 11
Q10. f(char *p)
{
p=(char *)malloc(6);
p="hello";
return;
}
main()
{
char *p="bye";
f(p);
printf("%s",p);
}
a)hello b)Hello bye c)bye d)none
Q11 main()
{
char a[10]="AaBbCc";
x(a);
}
x(char * a)
{
(a[0])?x(a+1):1;
printf("%c",*(a+0));
return 1;
}
a)AaBbCc b)cCbBaA c)none
Q12.which one will over flow given two programs
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
}
Q13. global variables in different files are
a)at compiletime
b) loading time
c) linking time
d)execution time
Q14. size of(int)
a) always 2 bytes
b) depends on compiler that is being used
c) always 32 bits
d) can't tell
Q15. variables of fuction call are allocated in
a) registers and stack
b) registers and heap
c) stack and heap
Q16. data structure used for priority queue
a) linked list b) double linked list c) array d) tree
Q17. 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 prints nothing
Q18 # define f(a,b) a+b
#defiune g(c,d) c*d
find valueof f(4,g(5,6))
a)26 b)51 c)36 d)error
Q19 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)prints nothing
Q20. 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
Q21)enum number { a = -1, b= 4,c,d,e}
what is the value of e ?
a)7 b)3 c)2 d)-4
Q22) main()
{
int i=0;
for(i=0;i<20;i++)
{
switch(i)
case 0:i+=5;
case 1:i+=2;
case 5:i+=5;
default i+=4;
break;}
printf("%d,",i);
}
}
a)0,5,9,13,17
b)5,9,13,17
c)12,17,22
d)16,21
e)syntax error
Q23) main()
{
char c=-64;
int i= -32;
unsigned int u = -16;
if(c>i){
printf("pass1,");
if(c<u)
printf("pass2");
else
printf("Fail2");}
else
printf("Fail1”);
if(i<u)
printf("pass2");
else
printf("Fail2")
}
a)Pass1,Pass2
b)Pass1,Fail2
c)Fail1,Pass2
d)Fail1,Fail2
e)none
Q24 void main()
{
int i;
char a[]="String";
char *p="New Sring";
char *Temp;
Temp=a;
a=malloc(strlen(p) + 1);
strcpy(a,p); //Line no:9//
p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);
printf("(%s, %s)",a,p);
free(p);
free(a);
} //Line no 15//
a) Swap contents of p & a and print:(New string, string)
b) Generate compilation error in line number 8
c) Generate compilation error in line number 5
d) Generate compilation error in line number 7
e) Generate compilation error in line number 1
Q25) char *gxxx()
{
static char xxx[1024];
return xxx;
}
main()
{
char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is : %s",gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these
Q26) Which of the choices is true for the mentioned declaration ?
const char *p;
and
char * const p;
a) You can't change the character in both
b) First : You can't change the characterr & Second : You can;t change the pointer
c) You can't change the pointer in both
d) First : You can't change the pointer & Second : You can't chanage the character
e) None
Q27) main()
{int a,b;
int *p,*q;
a=10;b=19;
p=&(a+b);
q=&max;
}
a)error in p=&(a+b) b)error in p=&max c)error in both d) no error
Q28) find(int x,int y)
{ return ((x<y)?0:(x-y)):}
call :find(a,find(a,b)) use to find
(a) maximum of a,b
(b) minimum of a,b
(c) positive difference of a,b
(d) sum of a,b
Q29) integer needs 2bytes , maximum value of an unsigned integer is
(a) { 2 power 16 } -1
(b) {2 power 15}-1
(c) {2 power16}
(d) {2 power 15}
Q30)y is of integer type then expression 3*(y-8)/9 and (y-8)/9*3 yields
(a)must yields same value
(b)must yields different value
(c)may or may not yields same value
(d) none of the above
31) printf("%f", 9/5);
prints
(a) 1.8
(b) 1.0
(c) 2.0
(d) none
Q32) if (a = 7)
printf(" a is 7 ");
else
printf("a is not 7");
(a) a is 7
(b) a is not 7,
(c) nothing,
(d) garbage.
Q33) if (a>b)
if(b>c)
s1;
else
s2 ;
s2 will be executed if
(a) a<= b
(b) b>c
(c) b<=c and a<=b
(d) a>b and b<=c.
Q34) main()
{
inc(); inc(); inc();
}
inc()
{ static int x;
printf("%d", ++x);
}
output:
(a) 012
(b) 123
(c) 3 consecutive unprectiable numbers
(d) 111.
Q35) preprocessing is done
(a) either before or at begining of compilation process
(b) after compilation before execution
(c) after loading
(d) none of the above.
Q36) printf("%d", sizeof(""));
output:
(a) error
(b)0
(c) garbage
(d) 1.
Q37) main()
{
int a=5,b=2;
printf("%d", a+++b);
}
(a) results in syntax error
(b) prints 7
(c) prints 8
(d) none
Q38) value of automatic variable that is declared but not intialized will be
(a) 0,
(b) -1,
(c) unpredictable,
(d) none
Q39)main(){
int v=3, *pv=&v;
printf(" %d %d ", v,*pv);
}
output will be:
(a) error
(b) 3 address of v,
(c) 3 3
(d) none.
Q40)
enum cities{bethlehem,jericho,nazareth=1,jerusalem}
value 1 will be assigned to:
(a) bethlehem
(b) nazareth
(c)bethlehem & nazareth
(d)jericho & Nazareth
Q41) #include <stdio.h>
main()
{
char line[80];
scanf("%[^\n]",line);
printf("%s",line);
}
what scanf do ?
(a) compilation error . illegal format string.
(b) terminates reading input
(c )reads i/p until end of line
(d)error
Q42) main ()
{
printf("%u" , main());
}
(a) print garbage.
(b) execution error
(c) printing of starting address of function main.
(d) infinite loop.
Q43)main(){
i =5;
i= (++i)/(i++);
printf( "%d" , i);}
prints :
(a) 2
(b) 5
(c) 1
(d) 6
Q44) int x[3][4] ={
{1,2,3},
{4,5,6},
{7,8,9}
}
which is true:
(a) x[2][1] = x[2][2] =x[2][3] = 0
(b) value in fourth column is zero
(c) value in last row is zero
(d) none of above.
Q45) For the following C program
#define AREA(x)(3.14*x*x)
main()
{float r1=6.25,r2=2.5,a;
a=AREA(r1);
printf("\n Area of the circle is %f", a);
a=AREA(r2);
printf("\n Area of the circle is %f", a);
}
What is the output?
Ans. Area of the circle is 122.656250
Area of the circle is 19.625000
Q46) 3. What do the following statements indicate. Explain.
· int(*p)[10]
· int*f()
· int(*pf)()
· int*p[10]
Q47) void main()
{
int d=5;
printf("%f",d);
}
a)5 b)5.0 c)undefined d)error
Q48) void main()
{
int i;
for(i=1;i<4,i++)
switch(i)
case 1: printf("%d",i);break;
{
case 2:printf("%d",i);break;
case 3:printf("%d",i);break;
}
switch(i) case 4:printf("%d",i);
}
a)1,2,3,4 b)error c)1,2,3 d)4
Q49) void main()
{
char *s="\12345s\n";
printf("%d",sizeof(s));}
a)5 b)6 c)compiler error d)none
Q50) void main()
{
unsigned i=1; /* unsigned char k= -1 => k=255; */
signed j=-1; /* char k= -1 => k=65535 */
/* unsigned or signed int k= -1 =>k=65535 */
if(i<j)
printf("less");
else
if(i>j)
printf("greater");
else
if(i==j)
printf("equal");
}
a)less b)greater c)equal d)none
Q51)void main()
{
float j;
j=1000*1000;
printf("%f",j);
}
1. 1000000
2. Overflow
3. Error
4. None
Q52) int f()
void main()
{
f(1);
f(1,2);
f(1,2,3);
}
f(int i,int j,int k)
{
printf("%d %d %d",i,j,k);
}
What are the number of syntax errors in the above
a)1 error b)2 error c)none
Q53) #define one 0
#ifdef one
printf("one is defined ");
#ifndef one
printf("one is not defined ");
a) one is defined b)one is not defined c)error
Q54) void main()
{
int count=10,*temp,sum=0;
temp=&count;
*temp=20;
temp=∑
*temp=count;
printf("%d %d %d ",count,*temp,sum);
}
a)10 20 20 b)20 20 10 c)20 20 20 d)none
Q55) main()
{
static i=3;
printf("%d",i--);
return i>0 ? main():0;
}
a)321 b)123 c)3 d)0
Q56) 19.
void main()
{
char *s[]={ "dharma","hewlett-packard","siemens","ibm"};
char **p;
p=s;
printf("%s",++*p);
printf("%s",*p++);
printf("%s",++*p);
}
Q57). What will the following program do?
void main()
{
int i;
char a[]="String";
char *p="New Sring";
char *Temp;
Temp=a;
a=malloc(strlen(p) + 1);
strcpy(a,p); //Line number:9//
p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);
printf("(%s, %s)",a,p);
free(p);
free(a);
} //Line number 15//
a) Swap contents of p & a and print:(New string, string)
b) Generate compilation error in line number 8
c) Generate compilation error in line number 5
d) Generate compilation error in line number 7
e) Generate compilation error in line number 1
Q58. In the following code segment what will be the result of the function, value of x , value of y
main()
{unsigned int x=-1;
int y;
y = ~0;
if(x == y)
printf("same");
else
printf("not same");
}
a) same, MAXINT, -1
b) not same, MAXINT, -MAXINT
c) same , MAXUNIT, -1
d) same, MAXUNIT, MAXUNIT
e) not same, MAXINT, MAXUNIT
Q59). What will be the result of the following program ?
char *gxxx()
{static char xxx[1024];
return xxx;
}
main()
{char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is : %s",gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these
Q60. Find the output for the following C program
main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
a)Name b)garbage value c)error d)An empty string
Q61. Find the output for the following C program
main()
{
int x=20,y=35;
x = y++ + x++;
y = ++y + ++x;
printf("%d %d\n",x,y);
}
a)55 57 b)56 57 c) 57 94 d)none
Q62)Which of the following language is predecessor to C Programming Language?
a)A b)B c)BCPL d)c++
63. Find the output for the following C program
main()
{
int x=5;
printf("%d %d %d\n",x,x<<2,x>>2);
}
a) 5 20 1 b)5 10 2 c)1 20 5 d)none
Q64) C programming language was developed by
a)Ken Thomson b)Peter Norton c)Dennis Ritchie
Q65) Find the output for the following C program
#define swap1(a,b) a=a+b;b=a-b;a=a-b;
main()
{
int x=5,y=10;
swap1(x,y);
printf("%d %d\n",x,y);
swap2(x,y);
printf("%d %d\n",x,y);
}
int swap2(int a,int b)
{
int temp;
temp=a;
b=a;
a=temp;
return;
}
a)5 10 b) 10 5 c)10 10 d)5 5
Q66) C is a ___ language
a)Low level b)high level c)Middle level d)all
Q67 Find the output for the following C program
main()
{
char *ptr = "Ramco Systems";
(*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s\n",ptr);
}
a)error b) amco Systems c)Ramco d)systems
Q68)C language is available for which of the following Operating Systems?
a)windows b)Unix c)DOS d)all of these
Q69) Find the output for the following C program
#include<stdio.h>
main()
{
char s1[]="wipro";
char s2[]="Systems";
s1=s2;
printf("%s",s1);
}
a)Run time error
b)wipro systems
c)Compiler error
d)lvalue error
Q70) Find the output for the following C program
#include<stdio.h>
main()
{
char *p1;
char *p2;
p1=(char *) malloc(25);
p2=(char *) malloc(25);
strcpy(p1,"wipro");
strcpy(p2,"Systems");
strcat(p1,p2);
printf("%s",p1);
}
a)Error b)systemswipro c) wiproSystems d)none
Q71) Which of the following is a Scalar Data type
a)float b)arrays c)union d)pointers
Q72). Find the output for the following C program
# define TRUE 0
some code
while(TRUE)
{
some code
}
a)Enter the loop
b)This won't go into the loop as TRUE is defined as 0
c)None
Q73. struct list{
int x;
struct list *next;
}*head;
the struct head.x =100
Is the above assignment to pointer is correct or wrong ?
a)correct b)error c) Wrong d)none
Q74).What is the output of the following ?
int i;
i=1;
i=i+2*i++;
printf(%d,i);
a)1 b)2 c)3 d) 4
Q75) Which of the following are tokens in C?
a)Keywords b)variables c)constants d)all of above
Q76). FILE *fp1,*fp2;
fp1=fopen("one","w")
fp2=fopen("one","w")
fputc('A',fp1)
fputc('B',fp2)
fclose(fp1)
fclose(fp2)
}
Find the Error, If Any?
a)error
b) no error. But It will over writes on same file.
c)writes to a new file
d)none
Q77)Which escape character can be used to beep from speaker in C?
a)\a b)\b c)\m d)\n
Q78. What are the output(s) for the following ?
#include<malloc.h>
char *f()
{char *s=malloc(8);
strcpy(s,"goodbye");
}
main()
{
char *f();
printf("%c",*f()='A'); }
a)A b)goodbye c)Error message d)none
Q79. #define MAN(x,y) (x)>(y)?(x):(y)
{int i=10;
j=5;
k=0;
k=MAX(i++,++j);
printf(%d %d %d %d,i,j,k);
}
a)50 10 b)10 50 c)none
Q80) The size of a String variable is
a)1 byte b)8 byte c)16 byte d)none of these
Q81).
void main()
{
int i=7;
printf("%d",i++*i++);
}
a)55 b)49 c)64 d)56
Q82) The maximum length of a variable in C is ___
a)8 byte b)16 byte c)32 byte d)64 byte
Q83) int x;
main()
{ int x=0;
{ int x=10;
x++;
change_value(x);
x++;
Modify_value();
printf("First output: %d\n",x);
}
x++;
change_value(x);
printf("Second Output : %d\n",x);
Modify_value();
printf("Third Output : %d\n",x);
}
Modify_value()
{
return (x+=10);
}
change_value()
{
return(x+=1);
}
a)1 1 12 b)1 12 1 c)12 1 1
84) main()
{ int x=10,y=15;
x=x++;
y=++y;
printf("%d %d\n",x,y);
}
a)16 11 b)10 16 c)11 16 d)none
Q85) main(){
int i=20,j,k=0;
for(j=1;j<i;j=1+4*(i/j))
{ k+=j<10?4:3;}
printf("%d", k);
}
a)4 b)3 c)0 d)5
Q86) #include
main()
{
extern int a;
printf("%d",a);;
}
int a=20;
(a) 20 (b) 0 (c) garbage value (d) error!!
Q87)main()
{
int a[5]={2,3};
printf("\n %d %d %d",a[2],a[3],a[4]);
}
a)garbage value (b) 2 3 3 (c) 3 2 2 (d) 0 0 0
Q88) main(){
inti=-3,j=2,k=0,m;
m=++i&&++j||++k;
printf("\n %d %d %d %d",i,j,k,m);
}
(a) -2 3 0 1 (b) -3 2 0 1 (c) -2 3 1 1 (d) error
Q89)#define CUBE(x) (x*x*x)
main()
{
int a,b=3;
a=CUBE(b++);
printf("\n %d %d",a,b);
}
(a) 64 4 (b) 27 4 (c) 27 6 (d) 64 6
Q90) What would be the output of the following program.
main()
{
const int x=get();
printf("%d",x);
}
get()
{
return(20);
}
(a) 20 (b) garbage value (c) error d) 0
Q91)pointout the error, if any, in the for loop
main()
{int l=1;
for(;;)
{
printf("%d",l++);
if(l>10)
break;
}
}
(a) The condition in the for loop is a must (b) The two semicolons should be dropped
(c) The for loop should be replaced by awhile loop (d) No error
Q92) int main(void)
{
char strA[10]="compile",strB[10];
my_strcpy(strB,strA);
puts(strB);
}
char * my_strcpy(char *destination,char *source)
{
char *p=destination;
while(*source!='\0')
{
*p++=*source++;
}
*p='\0';
return destination;
}
(a) Compilation will only give a warning but will proceed to execute & will display "compile"
(b) The compilation error char *(char *,char *) differs in levels of indirection from 'int()' will occur
(c) Yes & it will print compile on the screen (d) None of the above
Q93) #include<stdio.h>
main()
{
char str[5]="fast";
static char *ptr_to_array = str;
printf("%s",ptr_to_array);
}
(a) Compilation will only give a warning but will proceed to execute & will display "fast"
(b) display "fast" on screen
(c) will give a compilation error
(d) none of the above
Q94) main()
{
int num,*p;
num=5;
p=#
printf("%d",*p);
}
(a) 6 (b) 5 (c) junk value (d) compilation error
Q95)What would be the output of the following program.
main()
{
int a[3]={2,3,4};
char *p;
p=a;
p=(char *)((int *)p+1);
printf("%d",p);
}
(a) 2 (b) 0 (c) junk value (d) 3
Q96) main()
{
int i=10;
fn(i);
printf("%d",i);
}
fn(int i)
{
return ++i;
}
a)10 (b) 11 (c) 12 (d) Compilation error
Q97)What will be the value of i & j after the loop isexecuted?
for(i=0,j=0;i<5,j<25;i++,j++)
(a) i=4,j= 24 (b) i=24,j= 24 (c) i=25,j= 25 (d) i=5,j=25
Q98)What would be the output of the following program.
main()
{
int i,j;
i=10;
j=sizeof(++i);
printf("%d",i);
}
(a) 11 (b) 10 (c) 4 (d) compilation error
Q99) How many times the following program would print 'Jamboree'?
main()
{
printf("\n Jamboree");
main();
}
(a) infinite number of times (b) 32767 times
(c) 65535 times (d) till the stack does not overflow
Q100) What would be the output of the following program.
main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e = {"tiger"};
printf("\n %d %f",e.age,e.sal);
}
(a) 0 0.000000 (b) Garbage values (c) Error (d) none of the above
101) Preprocessor.. does not do which one of the following
(a) macro expansion
(b) conditional compliclation
(c) type checking
(d) including file
102) int i =10;
main()
{
int i =20,n;
for(n=0;n<=i;)
{
int i=10;
i++;
}
printf("%d", i);
}
a) i=20 b)10 c)0 d)none
103) What is the sizeof(long int)
(a) 4 bytes
(b) 2 bytes
(c) compiler dependent
(d) 8 bytes
104)Which is a good way of representing varaibles in recursion
a) local variables
b) static varaibles
c) global variables
105) Which of the following is not an infinite loop ?
(a) while(1)\{ ....} (b) for(;;){...}
(c) x=0; (d) # define TRUE 0
do{ /*x unaltered within the loop*/ ...
.....}while(x = = 0); while(TRUE){ ....}
106) Consider the following program
main()
{
int a[5]={1,3,6,7,0};
int *b;
b=&a[2];
}
The value of b[-1] is
(a) 1 (b) 3 (c) -6 (d) none
107) # define prod(a,b)=a*b
main()
{
int x=2;
int y=3;
printf("%d",prod(x+2,y-10));
}
the output of the program is
(a) 8 (b) 6 (c) 7 (d) None
108) Consider the following program segment
int n,sum=1;
switch(n)
{
case 2:sum=sum+2;
case 3:sum*=2;
break;
default:sum=0;
}
If n=2, what is the value of sum
(a) 0 (b) 6 (c) 3 (d) None of these
109) Identify the incorrect one
1.if(c=1)
2.if(c!=3)
3.if(a<b)then
4.if(c==1)
(a) 1 only (b) 1&3 (c) 3 only (d) All of the above
110) The format specifier for hexa decimal is
(a) %d (b) %o (c) %x (d) %u
111) main()
{
struct s1
{
char *str;
struct s1 *ptr;
};
static struct s1 arr[] = { {"Hyderabad",arr+1},
{"Bangalore",arr+2},
{"Delhi",arr}
};
struct s1 *p[3];
int i;
for(i=0;i<=2;i++)
p[i] = arr[i].ptr;
printf("%s\n",(*p)->str);
printf("%s\n",(++*p)->str);
printf("%s\n",((*p)++)->str);
}
a)Bangalore Hyderabad delhi b)delhi Bangalore Hyderabad
b)Bangalore Delhi Delhi d)none of the above
112) .main()
{
char *p = "hello world!";
p[0] = 'H';
printf("%s",p);
}
a)Hello world b)hello world c)none of the above d)error
113) In the following code, in which order the functions would be called?
a= f1(23,14)*f2(12/4)+f3();
a) f1, f2, f3 b) f3, f2, f1
c) The order may vary from compiler to compiler d) None of the above
114) What would be the output of the following program?
main()
{
int i=4;
switch(i)
{
default:
printf("\n A mouse is an elephant built by the Japanese");
case 1:
printf(" Breeding rabbits is a hair raising experience");
break;
case 2:
printf("\n Friction is a drag");
break;
case 3:
printf("\n If practice make perfect, then nobody's perfect");
}
}
a) A mouse is an elephant built by the Japanese b) Breeding rabbits is a hare raising experience
c) All of the above d) None of the above
115)If the 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;
for(i=0;i<argc;i++)
printf("%s",argv[i]);
}
a) 1 2 3 b) C:\MYPROG.EXE 1 2 3
c) MYP d) None of the above
116) If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday,
What would be the output?
main(int argc, char *argv[])
{
while(--argc >0)
printf("%s",*++argv);
}
a) myprog monday tuesday wednesday thursday b) monday tuesday wednesday Thursday
c) myprog tuesday thursday d) None of the above
117)What would be the output of the following program?
main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
a) 1 1 1 b) 1 2 4 c) 2 4 4 d) 4 4 4
118) According to ANSI specifications which is the correct way of declaring main() when it receives command line arguments?
a) main(int argc, char *argv[]) b) main(argc,argv) int argc; char *argv[];
c) main() {int argc; char *argv[]; } d) None of the above
119) What error would the following function give on compilation?
f(int a, int b)
{
int a;
a=20;
return a;
}
a) missing parenthesis in the return statement b) The function should be declared as int f(int a, int b)
c) redeclaration of a d) None of the above
120) In the following program how would you print 50 using p?
main()
{
int a[]={10, 20, 30, 40, 50};
char *p;
p= (char*) a;
}
Ans. printf("\n%d",*((int*)p+4));
121) #define PRINT(int) printf(" %d ",int)
main()
{int x,y,z;
x=03;y=02;z=01;
PRINT(x^x);
z<<=3;
PRINT(x);
y>>=3;
PRINT(y);
}
a)0 3 0 b)0 0 0 c)1 2 3 d)none
122)
main()
{
int a=10,b=20;
a>=5?b=100:b=200;
printf("%d\n",b);
}
a)100 b)200 c)error d)none of above
123) main(){
int a=10,b= 5,c=3,d=3;
if((a<b)&&(c=d++))
printf("%d %d %d %d", a,b,c,d);
else printf("%d %d %d %d", a,b,c,d);
}
a)10 5 3 b)5 3 10 c)3 5 10 d)none
124) Unsigned char c;
for(c=0;c!=256;c++2)
printf("%d",c);
No. of times the loop is executed ?
(a) 127
(b) 128
(c) 256
(d) infinitely
125) main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
}
a)10 b)Error c)1
126)
main
{
int x,j,k;
j=k=6;x=2;
x=j*k;
printf("%d", x);}
a)1 b)36 c)error d)none of above
127) main()
{
int x=2,y=6,z=6;
x=y==z;
printf("%d",x);
}
a)6 b)2 c)1 d)none
128) Which of the choices is true for the mentioned declaration ?
const char *p;
and
char * const p;
a) You can't change the character in both
b) First : You can't change the characterr &Second : You can;t change the pointer
c) You can't change the pointer in both
d) First : You can't change the pointer &Second : You can't chanage the character
e) None
129)How macros are called
a. Call by name
b. Call by refernce
c. Call by value
130) What would be the output of the following:
The base address starts from 6554
main( )
{
int a[10] ;
printf ( "%u %u", a, &a ) ;
}
a)6554 6558 b)6550 6554 c)6558 6554 d)none
131) Point out the error, if any in the following program.
main( )
{
extern int i ;
i = 20 ;
printf ( "%d", sizeof ( i ) ) ;
}
a)20 b)compiler error c)Linker error d)none
132) main( )
{
int a[3][4] = { 1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0 } ;
printf ( "\n %u %u", a + 1, &a + 1 ) ;
}
If the base address of array a is 65000
a)65000 65000 b) 65008 65024 c)Error d)none
133)The C language terminator is
(a) semicolon (b) colon (c) period (d) exclamation mark
134) What is false about the following -- A compound statement is
(a) A set of simple statements (b) Demarcated on either side by curly brackets
(c) Can be used in place of simple statement (d) A C function is not a compound statement.
135). What is true about the following C Functions
(a) Need not return any value (b) Should always return an integer
(c) Should always return a float (d) Should always return more than one value
136). Main must be written as
(a) The first function in the program (b) Second function in the program
(c) Last function in the program (d) Any where in the program
137). Which of the following about automatic variables within a function is correct?
(a) Its type must be declared before using the variable
(b) They are local (c) They are not initialized to zero (d) they are global
138) Write one statement equivalent to the following two statements: x=sqr(a); return(x);
Choose from one of the alternatives
(a) return(sqr(a)); (b) printf("sqr(a)");
(c) return(a*a*a); (d) printf("%d",sqr(a));
139) Which of the following about the C comments is incorrect?
(a) Comments can go over multiple lines
(b) Comments can start any where in the line
(c) A line can contain comments with out any language statements
(d) Comments can occur within comments
140) What is the value of y in the following code?
x=7;
y=0;
if(x=6) y=7;
else y=1;
(a) 7 (b) 0 (c) 1 (d) 6
141)Which of the following represents true statement either x is in the range of 10 and 50 or y is zero
(a) x >= 10 && x <= 50 || y = = 0 (b) x<50
(c) y!=10 && x>=50 (d) None of these
142)Which of the following is not an infinite loop ?
(a) while(1)\{ ....} (b) for(;;){...}
(c) x=0; (d) # define TRUE 0
do{ /*x unaltered within the loop*/ ...
.....}while(x = = 0); while(TRUE){ ....}
143)What does the following function print?
func(int i)
{
if(i%2)return 0;
else return 1;
}
main()
{
int =3;
i=func(i);
i=func(i);
printf("%d",i);
}
(a) 3 (b) 1 (c) 0 (d) 2
144)How does the C compiler interpret the following two statements
p=p+x;
q=q+y;
(a) p= p+x; (b)p=p+xq=q+y; (c)p= p+xq; (d)p=p+x/q=q+y;
q=q+y; q=q+y;
a.int b.char c.string d.float
145) Printf can be implemented by using __________ list.
a)Linked list
b)Variable length argument lists
c)double linked list
d)none
146) main()
{
int a=10,*j;
void *k;
j=k=&a;
j++;
k++;
printf("\n %u %u ",j,k);
}
a)junk value
b)11 11
c)10 10
d)Compiler error: Cannot increment a void pointer
147) main()
{
char a[4]="HELLO";
printf("%s",a);
}
a)Hello
b)prints nothing
c)Compiler error: Too many initializers
148) void main()
{
char ch;
for(ch=0;ch<=127;ch++)
printf(“%c %d \n“, ch, ch);
}
a)Implementaion dependent
b)Error
c)junk value
d)all of above
149) 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 value after executing this code?
(a) 200 (b) 1 (c) -1 (d) 50
150)A memory of 20 bytes is allocated to a string declared as char *s then the following two statements are executed:
s="Entrance"
l=strlen(s);
what is the value of l ?
(a)20 (b)8 (c)9 (d)21
151) 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}
152)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
153)Identify the in correct expression
(a)a=b=3=4; (b)a=b=c=d=0; (c)float a=int b= 3.5; (d)int a; floatb;a=b=3.5;
154)Regarding the scope of the varibles;identify the incorrect statement:
(a) automatic variables are automatically initialized to 0 (b) static variables are are automatically initialized to 0
(c) the address of a register variable is not accessible (d) static variables cannot be initialized with any expression
155) cond 1?cond 2?cond 3?:exp 1:exp 2:exp 3:exp 4;
is equivalent to which of the following?
(a) if cond 1
exp 1;
else if cond 2
exp 2;
else if cond 3
exp 3;
else exp 4;
(b) if cond 1
if cond 2
if cond 3
exp 1;
else exp 2;
else exp 3;
else exp 4;
(c) if cond 1 && cond 2 && cond 3
exp 1 |exp 2|exp 3|exp 4;
(d) if cond 3
exp 1;
else if cond 2 exp 2;
else if cond 3 exp 3;
else exp 4;
156)Which of the following is invalid
(a) a+=b (b) a*=b (c) a>>=b (d) a**=b
157) What does the following code do?
fn(int n, int p, int r)
{
static int a=p;
switch(n)
{
case 4:a+=a*r;
case 3:a+=a*r;
case 2:a+=a*r;
case 1:a+=a*r;
}
}
(a) computes simple interest for one year
(b) computes amount on compound interest for 1 to 4 years
(c) computes simple interest for four year (d) computes compound interest for 1 year
158)
a=0;
while(a<5)
printf("%d\\n",a++);
How many times does the loop occurs?
(a) infinite (b)5 (c)4 (d)6
159)How many times does the loop iterated ?
for(i=0;i=10;i+=2)
printf("Hi\\n");
(a)10 (b) 2 (c) 5 (d) None of these
160)What is incorrect among the following
A recursive function
(a) calls itself (b) is equivalent to a loop
(c) has a termination condition (d) does not have a return value at all
161)Which of the following go out of the loop if expn 2 becoming false
(a) while(expn 1)\{...if(expn 2)continue;} (b) while(!expn 1)\{if(expn 2)continue;...}
(c) do{..if(expn 1)continue;..}while(expn 2); (d) while(!expn 2)\{if(expn 1)continue;..\}
162)Consider the following program
main()
{
unsigned int i=10;
while(i>=0)
{
printf("%u",i)
i--;
}
}
How many times the loop will get executed
(a)10 (b)9 (c)11 (d) infinite
163)Pick out the odd one out
(a) malloc() (b) calloc() (c) free() (d) realloc()
164)Consider the following program
main()
{
int a[5]={1,3,6,7,0};
int *b;
b=&a[2];
}
The value of b[-1] is
(a) 1 (b) 3 (c) -6 (d) none
165) # define prod(a,b)=a*b
main()
{
int x=2;
int y=3;
printf("%d",prod(x+2,y-10));
}
the output of the program is
(a) 8 (b) 6 (c) 7 (d) None
166).Consider the following program segment
int n,sum=1;
switch(n)
{
case 2:sum=sum+2;
case 3:sum*=2;
break;
default:sum=0;
}
If n=2, what is the value of sum
(a) 0 (b) 6 (c) 3 (d) None of these
167)Identify the incorrect one
1.if(c=1)
2.if(c!=3)
3.if(a<b)then
4.if(c==1)
(a) 1 only (b) 1&3 (c) 3 only (d) All of the above
168)The format specified for hexa decimal is
(a) %d (b) %o (c) %x (d) %u
169)Find the output of the following program
main()
{
int x=5, *p;
p=&x
printf("%d",++*p);
}
(a) 5 (b) 6 (c) 0 (d) none of these
169)Consider the following C code
main()
{
int i=3,x;
while(i>0)
{
x=func(i);
i--;
}
int func(int n)
{
static sum=0;
sum=sum+n;
return(sum);
}
}
The final value of x is
(a) 6 (b) 8 (c) 1 (d) 3
170) Int *a[5] refers to
(a) array of pointers (b) pointer to an array (c) pointer to a pointer (d) none of these
171).Which of the following statements is incorrect
(a) typedef struct new
{
int n1;
char n2;
} DATA;
(b) typedef struct
{
int n3;
char *n4;
}ICE;
(c) typedef union
{
int n5;
float n6;
} UDT;
(d) #typedef union
{
int n7;
float n8;
} TUDAT;
172)Point out error, if any, in the following program
main()
{
int i=1;
switch(i)
{
case 1:
printf("\nRadioactive cats have 18 half-lives");
break;
case 1*2+4:
printf("\nBottle for rent -inquire within");
break;
}
}
Ans. No error. Constant expression like 1*2+4 are acceptable in cases of a switch.
173) Point out the error, if any, in the following program
main()
{
int a=10,b;
a>= 5 ? b=100 : b=200;
printf("\n%d",b);
}
Ans. lvalue required in function main(). The second assignment should be written in parenthesis as follows:
a>= 5 ? b=100 : (b=200);
174)In the following code, in which order the functions would be called?
a= f1(23,14)*f2(12/4)+f3();
a) f1, f2, f3 b) f3, f2, f1
c) The order may vary from compiler to compiler d) None of the above
175) What would be the output of the following program?
main()
{
int i=4;
switch(i)
{
default:
printf("\n A mouse is an elephant built by the Japanese");
case 1:
printf(" Breeding rabbits is a hair raising experience");
break;
case 2:
printf("\n Friction is a drag");
break;
case 3:
printf("\n If practice make perfect, then nobody's perfect");
}
}
a) A mouse is an elephant built by the Japanese b) Breeding rabbits is a hare raising experience
c) All of the above d) None of the above
176)What is the output of the following program?
#define SQR(x) (x*x)
main()
{
int a,b=3;
a= SQR(b+2);
printf("%d",a);
}
a) 25 b) 11 c) error d) garbage value
177) In which line of the following, an error would be reported?
1. #define CIRCUM(R) (3.14*R*R);
2. main()
3. {
4. float r=1.0,c;
5. c= CIRCUM(r);
6. printf("\n%f",c);
7. if(CIRCUM(r))==6.28)
8. printf("\nGobbledygook");
9. }
a) line 1 b) line 5 c) line 6 d) line 7
178) What is the type of the variable b in the following declaration?
#define FLOATPTR float*
FLOATPTR a,b;
a) float b) float pointer c) int d) int pointer
179). In the following code;
#include<stdio.h>
main()
{
FILE *fp;
fp= fopen("trial","r");
}
fp points to:
a) The first character in the file.
b) A structure which contains a "char" pointer which points to the first character in the file.
c) The name of the file. d) None of the above.
180.) We should not read after a write to a file without an intervening call to fflush(), fseek() or rewind() < TRUE/FALSE>
Ans. True
181). If the 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;
for(i=0;i<argc;i++)
printf("%s",argv[i]);
}
a) 1 2 3 b) C:\MYPROG.EXE 1 2 3
c) MYP d) None of the above
182). 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) 1 2 3 b) 6 c) error d) "123"
183). If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday,
What would be the output?
main(int argc, char *argv[])
{
while(--argc >0)
printf("%s",*++argv);
}
a) myprog monday tuesday wednesday thursday b) monday tuesday wednesday thursday
c) myprog tuesday thursday d) None of the above
184. In the following code, is p2 an integer or an integer pointer?
typedef int* ptr
ptr p1,p2;
Ans. Integer pointer
185. Point out the error in the following program
main()
{
const int x;
x=128;
printf("%d",x);
}
Ans. x should have been initialized where it is declared.
186. What would be the output of the following program?
main()
{
int y=128;
const int x=y;
printf("%d",x);
}
a) 128 b) Garbage value c) Error d) 0
187. What is the difference between the following declarations?
const char *s;
char const *s;
Ans. No difference
188. What is the difference between the following declarations?
const char *const s; char const *const s;
Ans. No difference
189. What would be the output of the following program?
main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
a) 1 1 1 b) 1 2 4 c) 2 4 4 d) 4 4 4
190. If the following program (myprog) is run from the command line as myprog friday tuesday sunday,
What would be the output?
main(int argc, char*argv[])
{
printf("%c",**++argv);
}
a) m b) f c) myprog d) friday
191. If the following program (myprog) is run from the command line as myprog friday tuesday sunday,
What would be the output?
main(int argc, char *argv[])
{
printf("%c",*++argv[1]);
}
a) r b) f c) m d) y
192. If the following program (myprog) is run from the command line as myprog friday tuesday sunday,
What would be the output?
main(int argc, char *argv[])
{
while(sizeofargv)
printf("%s",argv[--sizeofargv]);
}
a) myprog friday tuesday sunday b) myprog friday tuesday
c) sunday tuesday friday myprog d) sunday tuesday friday
193. Point out the error in the following program
main()
{
int a=10;
void f();
a=f();
printf("\n%d",a);
}
void f()
{
printf("\nHi");
}
Ans. The program is trying to collect the value of a "void" function into an integer variable.
194. In the following program how would you print 50 using p?
main()
{
int a[]={10, 20, 30, 40, 50};
char *p;
p= (char*) a;
}
Ans. printf("\n%d",*((int*)p+4));
195. Would the following program compile?
main()
{
int a=10,*j;
void *k;< BR> j=k=&a;
j++;
k++;
printf("\n%u%u",j,k);
}
a) Yes b) No, the format is incorrect
c) No, the arithmetic operation is not permitted on void pointers
d) No, the arithmetic operation is not permitted on pointers
196. According to ANSI specifications which is the correct way of declaring main() when it receives command line arguments?
a) main(int argc, char *argv[]) b) main(argc,argv) int argc; char *argv[];
c) main() {int argc; char *argv[]; } d) None of the above
197. What error would the following function give on compilation?
f(int a, int b)
{
int a;
a=20;
return a;
}
a) missing parenthesis in the return statement
b) The function should be declared as int f(int a, int b)
c) redeclaration of a d) None of the above
198. Point out the error in the following program
main()
{
const char *fun();
*fun()='A';
}
const char *fun()
{
return "Hello";
}
Ans. fun() returns to a "const char" pointer which cannot be modified
199. What would be the output of the following program?
main()
{
const int x=5;
int *ptrx;
ptrx=&x;
*ptrx=10;
printf("%d",x);
}
a) 5 b) 10 c) Error d) Garbage value
200. A switch statement cannot include
a) constants as arguments b) constant expression as arguments
c) string as an argument d) None of the above
201. How long the following program will run?
main()
{
printf("\nSonata Software");
main();
}
a) infinite loop b) until the stack overflows
c) All of the above d) None of the above
202. On combining the following statements, you will get char*p; p=malloc(100);
a) char *p= malloc(100) b) p= (char*)malloc(100)
c) All of the above d) None of the above
203. What is the output of the following program?
main()
{
int n=5;
printf("\nn=%*d",n,n);
}
a) n=5 b) n=5
c) n=5 d) error
204.What would be the output of the following program.
#include<stdio.h>
main()
{
extern int a;
printf("%d",a);;
}
int a=20;
(a) 20 (b) 0 (c) garbage value (d) error!!
205.What would be the output of the following program.
main()
{
int a[5]={2,3};
printf("\n %d %d %d",a[2],a[3],a[4]);
}
(a) garbage value (b) 2 3 3 (c) 3 2 2 (d) 0 0 0
206.What would be the output of the following program.
main()
{
inti=-3,j=2,k=0,m;
m=++i&&++j||++k;
printf("\n %d %d %d %d",i,j,k,m);
}
(a) -2 3 0 1 (b) -3 2 0 1 (c) -2 3 1 1 (d) error
207.What would be the output of the following program.
main()
{
int a,b;
a=sumdig(123);
b=sumdig(123);
printf("%d %d",a,b);
}
sumdig(int n)
{
static int s=0;
int d;
if(n!=0)
{
d=n%10;
n=(n-d)/10;
s=s+d;
sumdig(n);
}
else return(s);
}
(a) 12 6 (b) 6 12 (c) 3 15 (d) error
208.What would be the output of the following program.
#define CUBE(x) (x*x*x)
main()
{
int a,b=3;
a=CUBE(b++);
printf("\n %d %d",a,b);
}
(a) 64 4 (b) 27 4 (c) 27 6 (d) 64 6
209.What would be the output of the following program.
main()
{
const int x=get();
printf("%d",x);
}
get()
{
return(20);
}
(a) 20 (b) garbage value (c) error (d) 0
210.A function has this prototype void f1(int **x),
How will you call this function?
(a) int **a; (b) int a; (c) int *a; (d) int a=5;
f1(a); f1(&a); f1(&a); f1(&&a);
211.pointout the error, if any, in the for loop
main()
{
int l=1;
for(;;)
{
printf("%d",l++);
if(l>10)
break;
}
}
(a) The condition in the for loop is a must (b) The two semicolons should be dropped
(c) The for loop should be replaced by awhile loop (d) No error
212.Can the following piece of code be executed?
int main(void)
{
char strA[10]="compile",strB[10];
my_strcpy(strB,strA);
puts(strB);
}
char * my_strcpy(char *destination,char *source)
{
char *p=destination;
while(*source!='\0')
{
*p++=*source++;
}
*p='\0';
return destination;
}
(a) Compilation will only give a warning but will proceed to execute & will display "compile"
(b) The compilation error char *(char *,char *) differs in levels of indirection from 'int()' will occur
(c) Yes & it will print compile on the screen (d) None of the above
213.What would be the output of the following program.
#include<stdio.h>
main()
{
char str[5]="fast";
static char *ptr_to_array = str;
printf("%s",ptr_to_array);
}
(a) Compilation will only give a warning but will proceed to execute & will display "fast"
(b) display "fast" on screen (c) will give a compilation error (d) none of the above
214.What would be the output of the following program.
main()
{
int num,*p;
num=5;
p=#
printf("%d",*p);
}
(a) 6 (b) 5 (c) junk value (d) compilation error
215.What would be the output of the following program.
main()
{
int a[3]={2,3,4};
char *p;
p=a;
p=(char *)((int *)p+1);
printf("%d",p);
}
(a) 2 (b) 0 (c) junk value (d) 3
216.What would be the output of the following program.
main()
{
int i=10;
fn(i);
printf("%d",i);
}
fn(int i)
{
return ++i;
}
(a) 10 (b) 11 (c) 12 (d) Compilation error
217. What will be the value of i & j after the loop isexecuted?<BR> for(i=0,j=0;i<5,j<25;i++,j++)
(a) i=4,j= 24 (b) i=24,j= 24 (c) i=25,j= 25 (d) i=5,j=25
218.What would be the output of the following program.
main()
{
int i,j;
i=10;
j=sizeof(++i);
printf("%d",i);
}
(a) 11 (b) 10 (c) 4 (d) compilation error
219.What would be the output of the following program.
main()
{
int i=7;
printf("%d\n",i++*i++);
}
(a) 49 (b) 56 (c) 72 (d) compilation error
220. What will the printf print?
main()
{
char *p,*f();
p=f();
printf("f() returns:%s\n",p);
}
char *f()
{
char result[80];
strcpy(result,"anything will do");
return (result);
}
(a) f() returns: anything will do (b) f() returns:
(c) compilation error (d) The printf statement is not going to be executed
221.How many times the following program would print 'Jamboree'?
main()
{
printf("\n Jamboree");
main();
}
(a) infinite number of times (b) 32767 times
(c) 65535 times (d) till the stack does not overflow
222.Notice the error in the default statement in the code snippet below.Will it give a compilation error?
main()
{
int a=10,j;
j=fn(a);
switch(j)
{
case 30: printf("the value is 30");
break;
case 50: printf("the value is 50");
break;
default:printf("the value is not 30 or 50");
}
}
fn(int a)
{
return (++a);
}
(a) Will display "the value is 30"
(b) Will display "The value is not 30 or 50"
(c) Yes a compilation error would happen
(d) No compilation errors but there will be no output on the screen
223.What would be the output of the following program.
main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e = {"tiger"};
printf("\n %d %f",e.age,e.sal);
}
(a) 0 0.000000 (b) Garbage values (c) Error (d) none of the above
224)Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix and Postfix notations.
Prefix Notation:
^ - * +ABC - DE + FG(ans)
Postfix Notation:
AB + C * DE - - FG + ^ (ans)
225)Sorting is not possible by using which of the following methods?
(a) Insertion
(b) Selection
(c) Exchange
(d) Deletion
226)A binary tree with 20 nodes has 21 null branches?
227)How many different trees are possible with 3 nodes ? 5 ans.
228)In tree construction which is the suitable efficient data structure?
(a) Array (b) Linked list (c) Stack (d) Queue (e) none
229)Traverse the given tree using Inorder, Preorder and Postorder traversals.
Ø Inorder : D H B E A F C I G J(ans)
Ø Preorder: A B D H E C F G I J(ans)
Ø Postorder: H D E B F I J G C A(ans)
230)Draw a binary Tree for the expression :
A * B - (C + D) * (P / Q)
231) What is the time complexity of linear search algorithm over an array of n elements?
a. O (log2 n)
b. O (n) (ans)
c. O (n log2 n)
d. O (n2)
232). Which data structure is needed to convert infix notations to postfix notations?
a. Linear list
b. Queue.
c. Tree.
d. Stack. (ans)
233)A linear list of elements in which deletion can be done from one end(front) and insertion can take place only at the other end (rear) is known as
a. Queue (ans)
b. Stacks.
c. Trees.
d. Deque.
234)A binary tree in which of the levels except possibly the last, have the maximum number of nodes and all the nodes at the last level appear as far leaf as possible, is known as
a. Full binary tree.
b. 2-tree
c. Threaded tree.
d. Complete binary tree.(ans)
235)A list of integers are read in, one at a time and a binary search tree is constructed, Next the tree is traversed and the integers are printed. Which traversed would result in a printout which duplicates the original order of the list intergers ?
a. Preorder.
b. Postorder.
c. Inorder.
d. None of the above. (ans)
236) The time required to search an element in a binary search tree having n elements is
a O(1).
b. O(log2 n) (ans)
c. O(n)
d. O(n log2 n)
237)The infix expression (A+(B-C)*D) is correctly represented in prefix notation as
a. A+B-C*D
b. +A*-BCD
c. ABC-D*+
d. A+BC-D*
238) In what tree, for every node the height of its left subtree and right subtree differ atleast by one ?
a. Binary search tree.
b. AVL tree. (ans)
c. Complete tree.
d. Threaded binary tree.
239) main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}
a) 2 1 b) 1 1 c)1 2 d)none
240) main()
{
printf("%x",-1<<4);
}
a)fff0 b)4 c)0fff d)8
241) main(){
char string[]="Hello World";
display(string);
}
void display(char *string){
printf("%s",string);
}
a)Hello World b)Type mismatch error c)Linker error d)none
242) main()
{
int c= - -2;
printf("c=%d",c);
}
a)Error b)-2 c)2 d)none
243) #define int char
main()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}
a)Error b)1 c)2 d)A
244) main()
{
int i=10;
i= ! i>14;
printf ("i=%d",i);
}
a)1 b)10 c)0 d)none
245) #include<stdio.h>
main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
}
a)Garbage value b)0 c)10 d)5
246) main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
a)ab b)si c)ha d)hai
247) #include <stdio.h>
#define a 10
main()
{
#define a 50
printf("%d",a);
}
a)10 b)50 c)Compiler Error d)Linker Error
248) main()
{
printf("%p",main);
}
a)Some address b)Error c)none
249) void main()
{
char far *farther,*farthest;
printf("%d..%d",sizeof(farther),sizeof(farthest));
}
a)2 4 b)1 1 c)2 2 d)4 2
250) main()
{
char *p;
p="Hello";
printf("%c\n",*&*p);
}
a)H b)Error c)ello d)none
Q1.Correct
typedef struct {
char *item;
NODEPTR next;
} *NODEPTR;
Answer: struct node {
char *item;
struct node *next;
};
typedef struct node *NODEPTR
Q2 In signed magnitude what is the minimum value that can be represented with 8 bits?
a)-128
b)-255
c)-127
d)0
Q3. char *someFun1()
{
char temp[ ] = “string";
return temp;
}
char *someFun2()
{
char temp[ ] = {‘s’, ‘t’,’r’,’i’,’n’,’g’};
return temp;
}
int main()
{
puts(someFun1());
puts(someFun2());
}
a)Garbage values b)string c)Error.
Q4. #include<stdio.h>
main()
{
scanf("%d");
printf();
}
which of the following is correct?
a)compilation error
b)Run time error
c)No output
d)depends on the compiler
Q5 #include<stdio.h>
#define islower(c) ('a'<=(c) && (c)<='z')
#define toupper(c) (islower(c)?(c)-('a'-'A'):(c))
main()
{
char *p="i am fine";
while(*p)
printf("%c",toupper(*p++));
}
a)bcd
b)AFE
c)aFe
d)BCd
Q6.#include<stdio.h>
main()
{
200;
printf("tricky problem");
}
a)warning message
b)compilation error
c)run time error
d)none of these
Q7.#include<stdio.h>
main(){
int a=1,b=2,c=3;
printf("%d,%d",a,b,c);
}
a)1,2 b)2,1 c)Error d)2,3
Q8. int a[4]={1,2,3,4};
int *ptr;
ptr=a;
*(a+3)=*(++ptr)+(*ptr++);
A part of code is shown. The elements in a after
the execution of this code.
a.1 2 3 4 b. 1 2 3 6
c. compilation error d.1 2 2 4
Q9. #include<stdio.h>
proc();
main(){
int i;
for(i=0;i<2;i++)
proc();
}
proc() {
static i=10;
printf("%d",i++);
}
a)11 10 b)10,11 c)10 10 d)11 11
Q10. f(char *p)
{
p=(char *)malloc(6);
p="hello";
return;
}
main()
{
char *p="bye";
f(p);
printf("%s",p);
}
a)hello b)Hello bye c)bye d)none
Q11 main()
{
char a[10]="AaBbCc";
x(a);
}
x(char * a)
{
(a[0])?x(a+1):1;
printf("%c",*(a+0));
return 1;
}
a)AaBbCc b)cCbBaA c)none
Q12.which one will over flow given two programs
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
}
Q13. global variables in different files are
a)at compiletime
b) loading time
c) linking time
d)execution time
Q14. size of(int)
a) always 2 bytes
b) depends on compiler that is being used
c) always 32 bits
d) can't tell
Q15. variables of fuction call are allocated in
a) registers and stack
b) registers and heap
c) stack and heap
Q16. data structure used for priority queue
a) linked list b) double linked list c) array d) tree
Q17. 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 prints nothing
Q18 # define f(a,b) a+b
#defiune g(c,d) c*d
find valueof f(4,g(5,6))
a)26 b)51 c)36 d)error
Q19 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)prints nothing
Q20. 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
Q21)enum number { a = -1, b= 4,c,d,e}
what is the value of e ?
a)7 b)3 c)2 d)-4
Q22) main()
{
int i=0;
for(i=0;i<20;i++)
{
switch(i)
case 0:i+=5;
case 1:i+=2;
case 5:i+=5;
default i+=4;
break;}
printf("%d,",i);
}
}
a)0,5,9,13,17
b)5,9,13,17
c)12,17,22
d)16,21
e)syntax error
Q23) main()
{
char c=-64;
int i= -32;
unsigned int u = -16;
if(c>i){
printf("pass1,");
if(c<u)
printf("pass2");
else
printf("Fail2");}
else
printf("Fail1”);
if(i<u)
printf("pass2");
else
printf("Fail2")
}
a)Pass1,Pass2
b)Pass1,Fail2
c)Fail1,Pass2
d)Fail1,Fail2
e)none
Q24 void main()
{
int i;
char a[]="String";
char *p="New Sring";
char *Temp;
Temp=a;
a=malloc(strlen(p) + 1);
strcpy(a,p); //Line no:9//
p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);
printf("(%s, %s)",a,p);
free(p);
free(a);
} //Line no 15//
a) Swap contents of p & a and print:(New string, string)
b) Generate compilation error in line number 8
c) Generate compilation error in line number 5
d) Generate compilation error in line number 7
e) Generate compilation error in line number 1
Q25) char *gxxx()
{
static char xxx[1024];
return xxx;
}
main()
{
char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is : %s",gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these
Q26) Which of the choices is true for the mentioned declaration ?
const char *p;
and
char * const p;
a) You can't change the character in both
b) First : You can't change the characterr & Second : You can;t change the pointer
c) You can't change the pointer in both
d) First : You can't change the pointer & Second : You can't chanage the character
e) None
Q27) main()
{int a,b;
int *p,*q;
a=10;b=19;
p=&(a+b);
q=&max;
}
a)error in p=&(a+b) b)error in p=&max c)error in both d) no error
Q28) find(int x,int y)
{ return ((x<y)?0:(x-y)):}
call :find(a,find(a,b)) use to find
(a) maximum of a,b
(b) minimum of a,b
(c) positive difference of a,b
(d) sum of a,b
Q29) integer needs 2bytes , maximum value of an unsigned integer is
(a) { 2 power 16 } -1
(b) {2 power 15}-1
(c) {2 power16}
(d) {2 power 15}
Q30)y is of integer type then expression 3*(y-8)/9 and (y-8)/9*3 yields
(a)must yields same value
(b)must yields different value
(c)may or may not yields same value
(d) none of the above
31) printf("%f", 9/5);
prints
(a) 1.8
(b) 1.0
(c) 2.0
(d) none
Q32) if (a = 7)
printf(" a is 7 ");
else
printf("a is not 7");
(a) a is 7
(b) a is not 7,
(c) nothing,
(d) garbage.
Q33) if (a>b)
if(b>c)
s1;
else
s2 ;
s2 will be executed if
(a) a<= b
(b) b>c
(c) b<=c and a<=b
(d) a>b and b<=c.
Q34) main()
{
inc(); inc(); inc();
}
inc()
{ static int x;
printf("%d", ++x);
}
output:
(a) 012
(b) 123
(c) 3 consecutive unprectiable numbers
(d) 111.
Q35) preprocessing is done
(a) either before or at begining of compilation process
(b) after compilation before execution
(c) after loading
(d) none of the above.
Q36) printf("%d", sizeof(""));
output:
(a) error
(b)0
(c) garbage
(d) 1.
Q37) main()
{
int a=5,b=2;
printf("%d", a+++b);
}
(a) results in syntax error
(b) prints 7
(c) prints 8
(d) none
Q38) value of automatic variable that is declared but not intialized will be
(a) 0,
(b) -1,
(c) unpredictable,
(d) none
Q39)main(){
int v=3, *pv=&v;
printf(" %d %d ", v,*pv);
}
output will be:
(a) error
(b) 3 address of v,
(c) 3 3
(d) none.
Q40)
enum cities{bethlehem,jericho,nazareth=1,jerusalem}
value 1 will be assigned to:
(a) bethlehem
(b) nazareth
(c)bethlehem & nazareth
(d)jericho & Nazareth
Q41) #include <stdio.h>
main()
{
char line[80];
scanf("%[^\n]",line);
printf("%s",line);
}
what scanf do ?
(a) compilation error . illegal format string.
(b) terminates reading input
(c )reads i/p until end of line
(d)error
Q42) main ()
{
printf("%u" , main());
}
(a) print garbage.
(b) execution error
(c) printing of starting address of function main.
(d) infinite loop.
Q43)main(){
i =5;
i= (++i)/(i++);
printf( "%d" , i);}
prints :
(a) 2
(b) 5
(c) 1
(d) 6
Q44) int x[3][4] ={
{1,2,3},
{4,5,6},
{7,8,9}
}
which is true:
(a) x[2][1] = x[2][2] =x[2][3] = 0
(b) value in fourth column is zero
(c) value in last row is zero
(d) none of above.
Q45) For the following C program
#define AREA(x)(3.14*x*x)
main()
{float r1=6.25,r2=2.5,a;
a=AREA(r1);
printf("\n Area of the circle is %f", a);
a=AREA(r2);
printf("\n Area of the circle is %f", a);
}
What is the output?
Ans. Area of the circle is 122.656250
Area of the circle is 19.625000
Q46) 3. What do the following statements indicate. Explain.
· int(*p)[10]
· int*f()
· int(*pf)()
· int*p[10]
Q47) void main()
{
int d=5;
printf("%f",d);
}
a)5 b)5.0 c)undefined d)error
Q48) void main()
{
int i;
for(i=1;i<4,i++)
switch(i)
case 1: printf("%d",i);break;
{
case 2:printf("%d",i);break;
case 3:printf("%d",i);break;
}
switch(i) case 4:printf("%d",i);
}
a)1,2,3,4 b)error c)1,2,3 d)4
Q49) void main()
{
char *s="\12345s\n";
printf("%d",sizeof(s));}
a)5 b)6 c)compiler error d)none
Q50) void main()
{
unsigned i=1; /* unsigned char k= -1 => k=255; */
signed j=-1; /* char k= -1 => k=65535 */
/* unsigned or signed int k= -1 =>k=65535 */
if(i<j)
printf("less");
else
if(i>j)
printf("greater");
else
if(i==j)
printf("equal");
}
a)less b)greater c)equal d)none
Q51)void main()
{
float j;
j=1000*1000;
printf("%f",j);
}
1. 1000000
2. Overflow
3. Error
4. None
Q52) int f()
void main()
{
f(1);
f(1,2);
f(1,2,3);
}
f(int i,int j,int k)
{
printf("%d %d %d",i,j,k);
}
What are the number of syntax errors in the above
a)1 error b)2 error c)none
Q53) #define one 0
#ifdef one
printf("one is defined ");
#ifndef one
printf("one is not defined ");
a) one is defined b)one is not defined c)error
Q54) void main()
{
int count=10,*temp,sum=0;
temp=&count;
*temp=20;
temp=∑
*temp=count;
printf("%d %d %d ",count,*temp,sum);
}
a)10 20 20 b)20 20 10 c)20 20 20 d)none
Q55) main()
{
static i=3;
printf("%d",i--);
return i>0 ? main():0;
}
a)321 b)123 c)3 d)0
Q56) 19.
void main()
{
char *s[]={ "dharma","hewlett-packard","siemens","ibm"};
char **p;
p=s;
printf("%s",++*p);
printf("%s",*p++);
printf("%s",++*p);
}
Q57). What will the following program do?
void main()
{
int i;
char a[]="String";
char *p="New Sring";
char *Temp;
Temp=a;
a=malloc(strlen(p) + 1);
strcpy(a,p); //Line number:9//
p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);
printf("(%s, %s)",a,p);
free(p);
free(a);
} //Line number 15//
a) Swap contents of p & a and print:(New string, string)
b) Generate compilation error in line number 8
c) Generate compilation error in line number 5
d) Generate compilation error in line number 7
e) Generate compilation error in line number 1
Q58. In the following code segment what will be the result of the function, value of x , value of y
main()
{unsigned int x=-1;
int y;
y = ~0;
if(x == y)
printf("same");
else
printf("not same");
}
a) same, MAXINT, -1
b) not same, MAXINT, -MAXINT
c) same , MAXUNIT, -1
d) same, MAXUNIT, MAXUNIT
e) not same, MAXINT, MAXUNIT
Q59). What will be the result of the following program ?
char *gxxx()
{static char xxx[1024];
return xxx;
}
main()
{char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is : %s",gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these
Q60. Find the output for the following C program
main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
a)Name b)garbage value c)error d)An empty string
Q61. Find the output for the following C program
main()
{
int x=20,y=35;
x = y++ + x++;
y = ++y + ++x;
printf("%d %d\n",x,y);
}
a)55 57 b)56 57 c) 57 94 d)none
Q62)Which of the following language is predecessor to C Programming Language?
a)A b)B c)BCPL d)c++
63. Find the output for the following C program
main()
{
int x=5;
printf("%d %d %d\n",x,x<<2,x>>2);
}
a) 5 20 1 b)5 10 2 c)1 20 5 d)none
Q64) C programming language was developed by
a)Ken Thomson b)Peter Norton c)Dennis Ritchie
Q65) Find the output for the following C program
#define swap1(a,b) a=a+b;b=a-b;a=a-b;
main()
{
int x=5,y=10;
swap1(x,y);
printf("%d %d\n",x,y);
swap2(x,y);
printf("%d %d\n",x,y);
}
int swap2(int a,int b)
{
int temp;
temp=a;
b=a;
a=temp;
return;
}
a)5 10 b) 10 5 c)10 10 d)5 5
Q66) C is a ___ language
a)Low level b)high level c)Middle level d)all
Q67 Find the output for the following C program
main()
{
char *ptr = "Ramco Systems";
(*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s\n",ptr);
}
a)error b) amco Systems c)Ramco d)systems
Q68)C language is available for which of the following Operating Systems?
a)windows b)Unix c)DOS d)all of these
Q69) Find the output for the following C program
#include<stdio.h>
main()
{
char s1[]="wipro";
char s2[]="Systems";
s1=s2;
printf("%s",s1);
}
a)Run time error
b)wipro systems
c)Compiler error
d)lvalue error
Q70) Find the output for the following C program
#include<stdio.h>
main()
{
char *p1;
char *p2;
p1=(char *) malloc(25);
p2=(char *) malloc(25);
strcpy(p1,"wipro");
strcpy(p2,"Systems");
strcat(p1,p2);
printf("%s",p1);
}
a)Error b)systemswipro c) wiproSystems d)none
Q71) Which of the following is a Scalar Data type
a)float b)arrays c)union d)pointers
Q72). Find the output for the following C program
# define TRUE 0
some code
while(TRUE)
{
some code
}
a)Enter the loop
b)This won't go into the loop as TRUE is defined as 0
c)None
Q73. struct list{
int x;
struct list *next;
}*head;
the struct head.x =100
Is the above assignment to pointer is correct or wrong ?
a)correct b)error c) Wrong d)none
Q74).What is the output of the following ?
int i;
i=1;
i=i+2*i++;
printf(%d,i);
a)1 b)2 c)3 d) 4
Q75) Which of the following are tokens in C?
a)Keywords b)variables c)constants d)all of above
Q76). FILE *fp1,*fp2;
fp1=fopen("one","w")
fp2=fopen("one","w")
fputc('A',fp1)
fputc('B',fp2)
fclose(fp1)
fclose(fp2)
}
Find the Error, If Any?
a)error
b) no error. But It will over writes on same file.
c)writes to a new file
d)none
Q77)Which escape character can be used to beep from speaker in C?
a)\a b)\b c)\m d)\n
Q78. What are the output(s) for the following ?
#include<malloc.h>
char *f()
{char *s=malloc(8);
strcpy(s,"goodbye");
}
main()
{
char *f();
printf("%c",*f()='A'); }
a)A b)goodbye c)Error message d)none
Q79. #define MAN(x,y) (x)>(y)?(x):(y)
{int i=10;
j=5;
k=0;
k=MAX(i++,++j);
printf(%d %d %d %d,i,j,k);
}
a)50 10 b)10 50 c)none
Q80) The size of a String variable is
a)1 byte b)8 byte c)16 byte d)none of these
Q81).
void main()
{
int i=7;
printf("%d",i++*i++);
}
a)55 b)49 c)64 d)56
Q82) The maximum length of a variable in C is ___
a)8 byte b)16 byte c)32 byte d)64 byte
Q83) int x;
main()
{ int x=0;
{ int x=10;
x++;
change_value(x);
x++;
Modify_value();
printf("First output: %d\n",x);
}
x++;
change_value(x);
printf("Second Output : %d\n",x);
Modify_value();
printf("Third Output : %d\n",x);
}
Modify_value()
{
return (x+=10);
}
change_value()
{
return(x+=1);
}
a)1 1 12 b)1 12 1 c)12 1 1
84) main()
{ int x=10,y=15;
x=x++;
y=++y;
printf("%d %d\n",x,y);
}
a)16 11 b)10 16 c)11 16 d)none
Q85) main(){
int i=20,j,k=0;
for(j=1;j<i;j=1+4*(i/j))
{ k+=j<10?4:3;}
printf("%d", k);
}
a)4 b)3 c)0 d)5
Q86) #include
main()
{
extern int a;
printf("%d",a);;
}
int a=20;
(a) 20 (b) 0 (c) garbage value (d) error!!
Q87)main()
{
int a[5]={2,3};
printf("\n %d %d %d",a[2],a[3],a[4]);
}
a)garbage value (b) 2 3 3 (c) 3 2 2 (d) 0 0 0
Q88) main(){
inti=-3,j=2,k=0,m;
m=++i&&++j||++k;
printf("\n %d %d %d %d",i,j,k,m);
}
(a) -2 3 0 1 (b) -3 2 0 1 (c) -2 3 1 1 (d) error
Q89)#define CUBE(x) (x*x*x)
main()
{
int a,b=3;
a=CUBE(b++);
printf("\n %d %d",a,b);
}
(a) 64 4 (b) 27 4 (c) 27 6 (d) 64 6
Q90) What would be the output of the following program.
main()
{
const int x=get();
printf("%d",x);
}
get()
{
return(20);
}
(a) 20 (b) garbage value (c) error d) 0
Q91)pointout the error, if any, in the for loop
main()
{int l=1;
for(;;)
{
printf("%d",l++);
if(l>10)
break;
}
}
(a) The condition in the for loop is a must (b) The two semicolons should be dropped
(c) The for loop should be replaced by awhile loop (d) No error
Q92) int main(void)
{
char strA[10]="compile",strB[10];
my_strcpy(strB,strA);
puts(strB);
}
char * my_strcpy(char *destination,char *source)
{
char *p=destination;
while(*source!='\0')
{
*p++=*source++;
}
*p='\0';
return destination;
}
(a) Compilation will only give a warning but will proceed to execute & will display "compile"
(b) The compilation error char *(char *,char *) differs in levels of indirection from 'int()' will occur
(c) Yes & it will print compile on the screen (d) None of the above
Q93) #include<stdio.h>
main()
{
char str[5]="fast";
static char *ptr_to_array = str;
printf("%s",ptr_to_array);
}
(a) Compilation will only give a warning but will proceed to execute & will display "fast"
(b) display "fast" on screen
(c) will give a compilation error
(d) none of the above
Q94) main()
{
int num,*p;
num=5;
p=#
printf("%d",*p);
}
(a) 6 (b) 5 (c) junk value (d) compilation error
Q95)What would be the output of the following program.
main()
{
int a[3]={2,3,4};
char *p;
p=a;
p=(char *)((int *)p+1);
printf("%d",p);
}
(a) 2 (b) 0 (c) junk value (d) 3
Q96) main()
{
int i=10;
fn(i);
printf("%d",i);
}
fn(int i)
{
return ++i;
}
a)10 (b) 11 (c) 12 (d) Compilation error
Q97)What will be the value of i & j after the loop isexecuted?
for(i=0,j=0;i<5,j<25;i++,j++)
(a) i=4,j= 24 (b) i=24,j= 24 (c) i=25,j= 25 (d) i=5,j=25
Q98)What would be the output of the following program.
main()
{
int i,j;
i=10;
j=sizeof(++i);
printf("%d",i);
}
(a) 11 (b) 10 (c) 4 (d) compilation error
Q99) How many times the following program would print 'Jamboree'?
main()
{
printf("\n Jamboree");
main();
}
(a) infinite number of times (b) 32767 times
(c) 65535 times (d) till the stack does not overflow
Q100) What would be the output of the following program.
main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e = {"tiger"};
printf("\n %d %f",e.age,e.sal);
}
(a) 0 0.000000 (b) Garbage values (c) Error (d) none of the above
101) Preprocessor.. does not do which one of the following
(a) macro expansion
(b) conditional compliclation
(c) type checking
(d) including file
102) int i =10;
main()
{
int i =20,n;
for(n=0;n<=i;)
{
int i=10;
i++;
}
printf("%d", i);
}
a) i=20 b)10 c)0 d)none
103) What is the sizeof(long int)
(a) 4 bytes
(b) 2 bytes
(c) compiler dependent
(d) 8 bytes
104)Which is a good way of representing varaibles in recursion
a) local variables
b) static varaibles
c) global variables
105) Which of the following is not an infinite loop ?
(a) while(1)\{ ....} (b) for(;;){...}
(c) x=0; (d) # define TRUE 0
do{ /*x unaltered within the loop*/ ...
.....}while(x = = 0); while(TRUE){ ....}
106) Consider the following program
main()
{
int a[5]={1,3,6,7,0};
int *b;
b=&a[2];
}
The value of b[-1] is
(a) 1 (b) 3 (c) -6 (d) none
107) # define prod(a,b)=a*b
main()
{
int x=2;
int y=3;
printf("%d",prod(x+2,y-10));
}
the output of the program is
(a) 8 (b) 6 (c) 7 (d) None
108) Consider the following program segment
int n,sum=1;
switch(n)
{
case 2:sum=sum+2;
case 3:sum*=2;
break;
default:sum=0;
}
If n=2, what is the value of sum
(a) 0 (b) 6 (c) 3 (d) None of these
109) Identify the incorrect one
1.if(c=1)
2.if(c!=3)
3.if(a<b)then
4.if(c==1)
(a) 1 only (b) 1&3 (c) 3 only (d) All of the above
110) The format specifier for hexa decimal is
(a) %d (b) %o (c) %x (d) %u
111) main()
{
struct s1
{
char *str;
struct s1 *ptr;
};
static struct s1 arr[] = { {"Hyderabad",arr+1},
{"Bangalore",arr+2},
{"Delhi",arr}
};
struct s1 *p[3];
int i;
for(i=0;i<=2;i++)
p[i] = arr[i].ptr;
printf("%s\n",(*p)->str);
printf("%s\n",(++*p)->str);
printf("%s\n",((*p)++)->str);
}
a)Bangalore Hyderabad delhi b)delhi Bangalore Hyderabad
b)Bangalore Delhi Delhi d)none of the above
112) .main()
{
char *p = "hello world!";
p[0] = 'H';
printf("%s",p);
}
a)Hello world b)hello world c)none of the above d)error
113) In the following code, in which order the functions would be called?
a= f1(23,14)*f2(12/4)+f3();
a) f1, f2, f3 b) f3, f2, f1
c) The order may vary from compiler to compiler d) None of the above
114) What would be the output of the following program?
main()
{
int i=4;
switch(i)
{
default:
printf("\n A mouse is an elephant built by the Japanese");
case 1:
printf(" Breeding rabbits is a hair raising experience");
break;
case 2:
printf("\n Friction is a drag");
break;
case 3:
printf("\n If practice make perfect, then nobody's perfect");
}
}
a) A mouse is an elephant built by the Japanese b) Breeding rabbits is a hare raising experience
c) All of the above d) None of the above
115)If the 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;
for(i=0;i<argc;i++)
printf("%s",argv[i]);
}
a) 1 2 3 b) C:\MYPROG.EXE 1 2 3
c) MYP d) None of the above
116) If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday,
What would be the output?
main(int argc, char *argv[])
{
while(--argc >0)
printf("%s",*++argv);
}
a) myprog monday tuesday wednesday thursday b) monday tuesday wednesday Thursday
c) myprog tuesday thursday d) None of the above
117)What would be the output of the following program?
main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
a) 1 1 1 b) 1 2 4 c) 2 4 4 d) 4 4 4
118) According to ANSI specifications which is the correct way of declaring main() when it receives command line arguments?
a) main(int argc, char *argv[]) b) main(argc,argv) int argc; char *argv[];
c) main() {int argc; char *argv[]; } d) None of the above
119) What error would the following function give on compilation?
f(int a, int b)
{
int a;
a=20;
return a;
}
a) missing parenthesis in the return statement b) The function should be declared as int f(int a, int b)
c) redeclaration of a d) None of the above
120) In the following program how would you print 50 using p?
main()
{
int a[]={10, 20, 30, 40, 50};
char *p;
p= (char*) a;
}
Ans. printf("\n%d",*((int*)p+4));
121) #define PRINT(int) printf(" %d ",int)
main()
{int x,y,z;
x=03;y=02;z=01;
PRINT(x^x);
z<<=3;
PRINT(x);
y>>=3;
PRINT(y);
}
a)0 3 0 b)0 0 0 c)1 2 3 d)none
122)
main()
{
int a=10,b=20;
a>=5?b=100:b=200;
printf("%d\n",b);
}
a)100 b)200 c)error d)none of above
123) main(){
int a=10,b= 5,c=3,d=3;
if((a<b)&&(c=d++))
printf("%d %d %d %d", a,b,c,d);
else printf("%d %d %d %d", a,b,c,d);
}
a)10 5 3 b)5 3 10 c)3 5 10 d)none
124) Unsigned char c;
for(c=0;c!=256;c++2)
printf("%d",c);
No. of times the loop is executed ?
(a) 127
(b) 128
(c) 256
(d) infinitely
125) main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
}
a)10 b)Error c)1
126)
main
{
int x,j,k;
j=k=6;x=2;
x=j*k;
printf("%d", x);}
a)1 b)36 c)error d)none of above
127) main()
{
int x=2,y=6,z=6;
x=y==z;
printf("%d",x);
}
a)6 b)2 c)1 d)none
128) Which of the choices is true for the mentioned declaration ?
const char *p;
and
char * const p;
a) You can't change the character in both
b) First : You can't change the characterr &Second : You can;t change the pointer
c) You can't change the pointer in both
d) First : You can't change the pointer &Second : You can't chanage the character
e) None
129)How macros are called
a. Call by name
b. Call by refernce
c. Call by value
130) What would be the output of the following:
The base address starts from 6554
main( )
{
int a[10] ;
printf ( "%u %u", a, &a ) ;
}
a)6554 6558 b)6550 6554 c)6558 6554 d)none
131) Point out the error, if any in the following program.
main( )
{
extern int i ;
i = 20 ;
printf ( "%d", sizeof ( i ) ) ;
}
a)20 b)compiler error c)Linker error d)none
132) main( )
{
int a[3][4] = { 1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0 } ;
printf ( "\n %u %u", a + 1, &a + 1 ) ;
}
If the base address of array a is 65000
a)65000 65000 b) 65008 65024 c)Error d)none
133)The C language terminator is
(a) semicolon (b) colon (c) period (d) exclamation mark
134) What is false about the following -- A compound statement is
(a) A set of simple statements (b) Demarcated on either side by curly brackets
(c) Can be used in place of simple statement (d) A C function is not a compound statement.
135). What is true about the following C Functions
(a) Need not return any value (b) Should always return an integer
(c) Should always return a float (d) Should always return more than one value
136). Main must be written as
(a) The first function in the program (b) Second function in the program
(c) Last function in the program (d) Any where in the program
137). Which of the following about automatic variables within a function is correct?
(a) Its type must be declared before using the variable
(b) They are local (c) They are not initialized to zero (d) they are global
138) Write one statement equivalent to the following two statements: x=sqr(a); return(x);
Choose from one of the alternatives
(a) return(sqr(a)); (b) printf("sqr(a)");
(c) return(a*a*a); (d) printf("%d",sqr(a));
139) Which of the following about the C comments is incorrect?
(a) Comments can go over multiple lines
(b) Comments can start any where in the line
(c) A line can contain comments with out any language statements
(d) Comments can occur within comments
140) What is the value of y in the following code?
x=7;
y=0;
if(x=6) y=7;
else y=1;
(a) 7 (b) 0 (c) 1 (d) 6
141)Which of the following represents true statement either x is in the range of 10 and 50 or y is zero
(a) x >= 10 && x <= 50 || y = = 0 (b) x<50
(c) y!=10 && x>=50 (d) None of these
142)Which of the following is not an infinite loop ?
(a) while(1)\{ ....} (b) for(;;){...}
(c) x=0; (d) # define TRUE 0
do{ /*x unaltered within the loop*/ ...
.....}while(x = = 0); while(TRUE){ ....}
143)What does the following function print?
func(int i)
{
if(i%2)return 0;
else return 1;
}
main()
{
int =3;
i=func(i);
i=func(i);
printf("%d",i);
}
(a) 3 (b) 1 (c) 0 (d) 2
144)How does the C compiler interpret the following two statements
p=p+x;
q=q+y;
(a) p= p+x; (b)p=p+xq=q+y; (c)p= p+xq; (d)p=p+x/q=q+y;
q=q+y; q=q+y;
a.int b.char c.string d.float
145) Printf can be implemented by using __________ list.
a)Linked list
b)Variable length argument lists
c)double linked list
d)none
146) main()
{
int a=10,*j;
void *k;
j=k=&a;
j++;
k++;
printf("\n %u %u ",j,k);
}
a)junk value
b)11 11
c)10 10
d)Compiler error: Cannot increment a void pointer
147) main()
{
char a[4]="HELLO";
printf("%s",a);
}
a)Hello
b)prints nothing
c)Compiler error: Too many initializers
148) void main()
{
char ch;
for(ch=0;ch<=127;ch++)
printf(“%c %d \n“, ch, ch);
}
a)Implementaion dependent
b)Error
c)junk value
d)all of above
149) 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 value after executing this code?
(a) 200 (b) 1 (c) -1 (d) 50
150)A memory of 20 bytes is allocated to a string declared as char *s then the following two statements are executed:
s="Entrance"
l=strlen(s);
what is the value of l ?
(a)20 (b)8 (c)9 (d)21
151) 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}
152)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
153)Identify the in correct expression
(a)a=b=3=4; (b)a=b=c=d=0; (c)float a=int b= 3.5; (d)int a; floatb;a=b=3.5;
154)Regarding the scope of the varibles;identify the incorrect statement:
(a) automatic variables are automatically initialized to 0 (b) static variables are are automatically initialized to 0
(c) the address of a register variable is not accessible (d) static variables cannot be initialized with any expression
155) cond 1?cond 2?cond 3?:exp 1:exp 2:exp 3:exp 4;
is equivalent to which of the following?
(a) if cond 1
exp 1;
else if cond 2
exp 2;
else if cond 3
exp 3;
else exp 4;
(b) if cond 1
if cond 2
if cond 3
exp 1;
else exp 2;
else exp 3;
else exp 4;
(c) if cond 1 && cond 2 && cond 3
exp 1 |exp 2|exp 3|exp 4;
(d) if cond 3
exp 1;
else if cond 2 exp 2;
else if cond 3 exp 3;
else exp 4;
156)Which of the following is invalid
(a) a+=b (b) a*=b (c) a>>=b (d) a**=b
157) What does the following code do?
fn(int n, int p, int r)
{
static int a=p;
switch(n)
{
case 4:a+=a*r;
case 3:a+=a*r;
case 2:a+=a*r;
case 1:a+=a*r;
}
}
(a) computes simple interest for one year
(b) computes amount on compound interest for 1 to 4 years
(c) computes simple interest for four year (d) computes compound interest for 1 year
158)
a=0;
while(a<5)
printf("%d\\n",a++);
How many times does the loop occurs?
(a) infinite (b)5 (c)4 (d)6
159)How many times does the loop iterated ?
for(i=0;i=10;i+=2)
printf("Hi\\n");
(a)10 (b) 2 (c) 5 (d) None of these
160)What is incorrect among the following
A recursive function
(a) calls itself (b) is equivalent to a loop
(c) has a termination condition (d) does not have a return value at all
161)Which of the following go out of the loop if expn 2 becoming false
(a) while(expn 1)\{...if(expn 2)continue;} (b) while(!expn 1)\{if(expn 2)continue;...}
(c) do{..if(expn 1)continue;..}while(expn 2); (d) while(!expn 2)\{if(expn 1)continue;..\}
162)Consider the following program
main()
{
unsigned int i=10;
while(i>=0)
{
printf("%u",i)
i--;
}
}
How many times the loop will get executed
(a)10 (b)9 (c)11 (d) infinite
163)Pick out the odd one out
(a) malloc() (b) calloc() (c) free() (d) realloc()
164)Consider the following program
main()
{
int a[5]={1,3,6,7,0};
int *b;
b=&a[2];
}
The value of b[-1] is
(a) 1 (b) 3 (c) -6 (d) none
165) # define prod(a,b)=a*b
main()
{
int x=2;
int y=3;
printf("%d",prod(x+2,y-10));
}
the output of the program is
(a) 8 (b) 6 (c) 7 (d) None
166).Consider the following program segment
int n,sum=1;
switch(n)
{
case 2:sum=sum+2;
case 3:sum*=2;
break;
default:sum=0;
}
If n=2, what is the value of sum
(a) 0 (b) 6 (c) 3 (d) None of these
167)Identify the incorrect one
1.if(c=1)
2.if(c!=3)
3.if(a<b)then
4.if(c==1)
(a) 1 only (b) 1&3 (c) 3 only (d) All of the above
168)The format specified for hexa decimal is
(a) %d (b) %o (c) %x (d) %u
169)Find the output of the following program
main()
{
int x=5, *p;
p=&x
printf("%d",++*p);
}
(a) 5 (b) 6 (c) 0 (d) none of these
169)Consider the following C code
main()
{
int i=3,x;
while(i>0)
{
x=func(i);
i--;
}
int func(int n)
{
static sum=0;
sum=sum+n;
return(sum);
}
}
The final value of x is
(a) 6 (b) 8 (c) 1 (d) 3
170) Int *a[5] refers to
(a) array of pointers (b) pointer to an array (c) pointer to a pointer (d) none of these
171).Which of the following statements is incorrect
(a) typedef struct new
{
int n1;
char n2;
} DATA;
(b) typedef struct
{
int n3;
char *n4;
}ICE;
(c) typedef union
{
int n5;
float n6;
} UDT;
(d) #typedef union
{
int n7;
float n8;
} TUDAT;
172)Point out error, if any, in the following program
main()
{
int i=1;
switch(i)
{
case 1:
printf("\nRadioactive cats have 18 half-lives");
break;
case 1*2+4:
printf("\nBottle for rent -inquire within");
break;
}
}
Ans. No error. Constant expression like 1*2+4 are acceptable in cases of a switch.
173) Point out the error, if any, in the following program
main()
{
int a=10,b;
a>= 5 ? b=100 : b=200;
printf("\n%d",b);
}
Ans. lvalue required in function main(). The second assignment should be written in parenthesis as follows:
a>= 5 ? b=100 : (b=200);
174)In the following code, in which order the functions would be called?
a= f1(23,14)*f2(12/4)+f3();
a) f1, f2, f3 b) f3, f2, f1
c) The order may vary from compiler to compiler d) None of the above
175) What would be the output of the following program?
main()
{
int i=4;
switch(i)
{
default:
printf("\n A mouse is an elephant built by the Japanese");
case 1:
printf(" Breeding rabbits is a hair raising experience");
break;
case 2:
printf("\n Friction is a drag");
break;
case 3:
printf("\n If practice make perfect, then nobody's perfect");
}
}
a) A mouse is an elephant built by the Japanese b) Breeding rabbits is a hare raising experience
c) All of the above d) None of the above
176)What is the output of the following program?
#define SQR(x) (x*x)
main()
{
int a,b=3;
a= SQR(b+2);
printf("%d",a);
}
a) 25 b) 11 c) error d) garbage value
177) In which line of the following, an error would be reported?
1. #define CIRCUM(R) (3.14*R*R);
2. main()
3. {
4. float r=1.0,c;
5. c= CIRCUM(r);
6. printf("\n%f",c);
7. if(CIRCUM(r))==6.28)
8. printf("\nGobbledygook");
9. }
a) line 1 b) line 5 c) line 6 d) line 7
178) What is the type of the variable b in the following declaration?
#define FLOATPTR float*
FLOATPTR a,b;
a) float b) float pointer c) int d) int pointer
179). In the following code;
#include<stdio.h>
main()
{
FILE *fp;
fp= fopen("trial","r");
}
fp points to:
a) The first character in the file.
b) A structure which contains a "char" pointer which points to the first character in the file.
c) The name of the file. d) None of the above.
180.) We should not read after a write to a file without an intervening call to fflush(), fseek() or rewind() < TRUE/FALSE>
Ans. True
181). If the 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;
for(i=0;i<argc;i++)
printf("%s",argv[i]);
}
a) 1 2 3 b) C:\MYPROG.EXE 1 2 3
c) MYP d) None of the above
182). 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) 1 2 3 b) 6 c) error d) "123"
183). If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday,
What would be the output?
main(int argc, char *argv[])
{
while(--argc >0)
printf("%s",*++argv);
}
a) myprog monday tuesday wednesday thursday b) monday tuesday wednesday thursday
c) myprog tuesday thursday d) None of the above
184. In the following code, is p2 an integer or an integer pointer?
typedef int* ptr
ptr p1,p2;
Ans. Integer pointer
185. Point out the error in the following program
main()
{
const int x;
x=128;
printf("%d",x);
}
Ans. x should have been initialized where it is declared.
186. What would be the output of the following program?
main()
{
int y=128;
const int x=y;
printf("%d",x);
}
a) 128 b) Garbage value c) Error d) 0
187. What is the difference between the following declarations?
const char *s;
char const *s;
Ans. No difference
188. What is the difference between the following declarations?
const char *const s; char const *const s;
Ans. No difference
189. What would be the output of the following program?
main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
a) 1 1 1 b) 1 2 4 c) 2 4 4 d) 4 4 4
190. If the following program (myprog) is run from the command line as myprog friday tuesday sunday,
What would be the output?
main(int argc, char*argv[])
{
printf("%c",**++argv);
}
a) m b) f c) myprog d) friday
191. If the following program (myprog) is run from the command line as myprog friday tuesday sunday,
What would be the output?
main(int argc, char *argv[])
{
printf("%c",*++argv[1]);
}
a) r b) f c) m d) y
192. If the following program (myprog) is run from the command line as myprog friday tuesday sunday,
What would be the output?
main(int argc, char *argv[])
{
while(sizeofargv)
printf("%s",argv[--sizeofargv]);
}
a) myprog friday tuesday sunday b) myprog friday tuesday
c) sunday tuesday friday myprog d) sunday tuesday friday
193. Point out the error in the following program
main()
{
int a=10;
void f();
a=f();
printf("\n%d",a);
}
void f()
{
printf("\nHi");
}
Ans. The program is trying to collect the value of a "void" function into an integer variable.
194. In the following program how would you print 50 using p?
main()
{
int a[]={10, 20, 30, 40, 50};
char *p;
p= (char*) a;
}
Ans. printf("\n%d",*((int*)p+4));
195. Would the following program compile?
main()
{
int a=10,*j;
void *k;< BR> j=k=&a;
j++;
k++;
printf("\n%u%u",j,k);
}
a) Yes b) No, the format is incorrect
c) No, the arithmetic operation is not permitted on void pointers
d) No, the arithmetic operation is not permitted on pointers
196. According to ANSI specifications which is the correct way of declaring main() when it receives command line arguments?
a) main(int argc, char *argv[]) b) main(argc,argv) int argc; char *argv[];
c) main() {int argc; char *argv[]; } d) None of the above
197. What error would the following function give on compilation?
f(int a, int b)
{
int a;
a=20;
return a;
}
a) missing parenthesis in the return statement
b) The function should be declared as int f(int a, int b)
c) redeclaration of a d) None of the above
198. Point out the error in the following program
main()
{
const char *fun();
*fun()='A';
}
const char *fun()
{
return "Hello";
}
Ans. fun() returns to a "const char" pointer which cannot be modified
199. What would be the output of the following program?
main()
{
const int x=5;
int *ptrx;
ptrx=&x;
*ptrx=10;
printf("%d",x);
}
a) 5 b) 10 c) Error d) Garbage value
200. A switch statement cannot include
a) constants as arguments b) constant expression as arguments
c) string as an argument d) None of the above
201. How long the following program will run?
main()
{
printf("\nSonata Software");
main();
}
a) infinite loop b) until the stack overflows
c) All of the above d) None of the above
202. On combining the following statements, you will get char*p; p=malloc(100);
a) char *p= malloc(100) b) p= (char*)malloc(100)
c) All of the above d) None of the above
203. What is the output of the following program?
main()
{
int n=5;
printf("\nn=%*d",n,n);
}
a) n=5 b) n=5
c) n=5 d) error
204.What would be the output of the following program.
#include<stdio.h>
main()
{
extern int a;
printf("%d",a);;
}
int a=20;
(a) 20 (b) 0 (c) garbage value (d) error!!
205.What would be the output of the following program.
main()
{
int a[5]={2,3};
printf("\n %d %d %d",a[2],a[3],a[4]);
}
(a) garbage value (b) 2 3 3 (c) 3 2 2 (d) 0 0 0
206.What would be the output of the following program.
main()
{
inti=-3,j=2,k=0,m;
m=++i&&++j||++k;
printf("\n %d %d %d %d",i,j,k,m);
}
(a) -2 3 0 1 (b) -3 2 0 1 (c) -2 3 1 1 (d) error
207.What would be the output of the following program.
main()
{
int a,b;
a=sumdig(123);
b=sumdig(123);
printf("%d %d",a,b);
}
sumdig(int n)
{
static int s=0;
int d;
if(n!=0)
{
d=n%10;
n=(n-d)/10;
s=s+d;
sumdig(n);
}
else return(s);
}
(a) 12 6 (b) 6 12 (c) 3 15 (d) error
208.What would be the output of the following program.
#define CUBE(x) (x*x*x)
main()
{
int a,b=3;
a=CUBE(b++);
printf("\n %d %d",a,b);
}
(a) 64 4 (b) 27 4 (c) 27 6 (d) 64 6
209.What would be the output of the following program.
main()
{
const int x=get();
printf("%d",x);
}
get()
{
return(20);
}
(a) 20 (b) garbage value (c) error (d) 0
210.A function has this prototype void f1(int **x),
How will you call this function?
(a) int **a; (b) int a; (c) int *a; (d) int a=5;
f1(a); f1(&a); f1(&a); f1(&&a);
211.pointout the error, if any, in the for loop
main()
{
int l=1;
for(;;)
{
printf("%d",l++);
if(l>10)
break;
}
}
(a) The condition in the for loop is a must (b) The two semicolons should be dropped
(c) The for loop should be replaced by awhile loop (d) No error
212.Can the following piece of code be executed?
int main(void)
{
char strA[10]="compile",strB[10];
my_strcpy(strB,strA);
puts(strB);
}
char * my_strcpy(char *destination,char *source)
{
char *p=destination;
while(*source!='\0')
{
*p++=*source++;
}
*p='\0';
return destination;
}
(a) Compilation will only give a warning but will proceed to execute & will display "compile"
(b) The compilation error char *(char *,char *) differs in levels of indirection from 'int()' will occur
(c) Yes & it will print compile on the screen (d) None of the above
213.What would be the output of the following program.
#include<stdio.h>
main()
{
char str[5]="fast";
static char *ptr_to_array = str;
printf("%s",ptr_to_array);
}
(a) Compilation will only give a warning but will proceed to execute & will display "fast"
(b) display "fast" on screen (c) will give a compilation error (d) none of the above
214.What would be the output of the following program.
main()
{
int num,*p;
num=5;
p=#
printf("%d",*p);
}
(a) 6 (b) 5 (c) junk value (d) compilation error
215.What would be the output of the following program.
main()
{
int a[3]={2,3,4};
char *p;
p=a;
p=(char *)((int *)p+1);
printf("%d",p);
}
(a) 2 (b) 0 (c) junk value (d) 3
216.What would be the output of the following program.
main()
{
int i=10;
fn(i);
printf("%d",i);
}
fn(int i)
{
return ++i;
}
(a) 10 (b) 11 (c) 12 (d) Compilation error
217. What will be the value of i & j after the loop isexecuted?<BR> for(i=0,j=0;i<5,j<25;i++,j++)
(a) i=4,j= 24 (b) i=24,j= 24 (c) i=25,j= 25 (d) i=5,j=25
218.What would be the output of the following program.
main()
{
int i,j;
i=10;
j=sizeof(++i);
printf("%d",i);
}
(a) 11 (b) 10 (c) 4 (d) compilation error
219.What would be the output of the following program.
main()
{
int i=7;
printf("%d\n",i++*i++);
}
(a) 49 (b) 56 (c) 72 (d) compilation error
220. What will the printf print?
main()
{
char *p,*f();
p=f();
printf("f() returns:%s\n",p);
}
char *f()
{
char result[80];
strcpy(result,"anything will do");
return (result);
}
(a) f() returns: anything will do (b) f() returns:
(c) compilation error (d) The printf statement is not going to be executed
221.How many times the following program would print 'Jamboree'?
main()
{
printf("\n Jamboree");
main();
}
(a) infinite number of times (b) 32767 times
(c) 65535 times (d) till the stack does not overflow
222.Notice the error in the default statement in the code snippet below.Will it give a compilation error?
main()
{
int a=10,j;
j=fn(a);
switch(j)
{
case 30: printf("the value is 30");
break;
case 50: printf("the value is 50");
break;
default:printf("the value is not 30 or 50");
}
}
fn(int a)
{
return (++a);
}
(a) Will display "the value is 30"
(b) Will display "The value is not 30 or 50"
(c) Yes a compilation error would happen
(d) No compilation errors but there will be no output on the screen
223.What would be the output of the following program.
main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e = {"tiger"};
printf("\n %d %f",e.age,e.sal);
}
(a) 0 0.000000 (b) Garbage values (c) Error (d) none of the above
224)Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix and Postfix notations.
Prefix Notation:
^ - * +ABC - DE + FG(ans)
Postfix Notation:
AB + C * DE - - FG + ^ (ans)
225)Sorting is not possible by using which of the following methods?
(a) Insertion
(b) Selection
(c) Exchange
(d) Deletion
226)A binary tree with 20 nodes has 21 null branches?
227)How many different trees are possible with 3 nodes ? 5 ans.
228)In tree construction which is the suitable efficient data structure?
(a) Array (b) Linked list (c) Stack (d) Queue (e) none
229)Traverse the given tree using Inorder, Preorder and Postorder traversals.
Ø Inorder : D H B E A F C I G J(ans)
Ø Preorder: A B D H E C F G I J(ans)
Ø Postorder: H D E B F I J G C A(ans)
230)Draw a binary Tree for the expression :
A * B - (C + D) * (P / Q)
231) What is the time complexity of linear search algorithm over an array of n elements?
a. O (log2 n)
b. O (n) (ans)
c. O (n log2 n)
d. O (n2)
232). Which data structure is needed to convert infix notations to postfix notations?
a. Linear list
b. Queue.
c. Tree.
d. Stack. (ans)
233)A linear list of elements in which deletion can be done from one end(front) and insertion can take place only at the other end (rear) is known as
a. Queue (ans)
b. Stacks.
c. Trees.
d. Deque.
234)A binary tree in which of the levels except possibly the last, have the maximum number of nodes and all the nodes at the last level appear as far leaf as possible, is known as
a. Full binary tree.
b. 2-tree
c. Threaded tree.
d. Complete binary tree.(ans)
235)A list of integers are read in, one at a time and a binary search tree is constructed, Next the tree is traversed and the integers are printed. Which traversed would result in a printout which duplicates the original order of the list intergers ?
a. Preorder.
b. Postorder.
c. Inorder.
d. None of the above. (ans)
236) The time required to search an element in a binary search tree having n elements is
a O(1).
b. O(log2 n) (ans)
c. O(n)
d. O(n log2 n)
237)The infix expression (A+(B-C)*D) is correctly represented in prefix notation as
a. A+B-C*D
b. +A*-BCD
c. ABC-D*+
d. A+BC-D*
238) In what tree, for every node the height of its left subtree and right subtree differ atleast by one ?
a. Binary search tree.
b. AVL tree. (ans)
c. Complete tree.
d. Threaded binary tree.
239) main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}
a) 2 1 b) 1 1 c)1 2 d)none
240) main()
{
printf("%x",-1<<4);
}
a)fff0 b)4 c)0fff d)8
241) main(){
char string[]="Hello World";
display(string);
}
void display(char *string){
printf("%s",string);
}
a)Hello World b)Type mismatch error c)Linker error d)none
242) main()
{
int c= - -2;
printf("c=%d",c);
}
a)Error b)-2 c)2 d)none
243) #define int char
main()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}
a)Error b)1 c)2 d)A
244) main()
{
int i=10;
i= ! i>14;
printf ("i=%d",i);
}
a)1 b)10 c)0 d)none
245) #include<stdio.h>
main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
}
a)Garbage value b)0 c)10 d)5
246) main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
a)ab b)si c)ha d)hai
247) #include <stdio.h>
#define a 10
main()
{
#define a 50
printf("%d",a);
}
a)10 b)50 c)Compiler Error d)Linker Error
248) main()
{
printf("%p",main);
}
a)Some address b)Error c)none
249) void main()
{
char far *farther,*farthest;
printf("%d..%d",sizeof(farther),sizeof(farthest));
}
a)2 4 b)1 1 c)2 2 d)4 2
250) main()
{
char *p;
p="Hello";
printf("%c\n",*&*p);
}
a)H b)Error c)ello d)none