You are on page 1of 59

TECHNICAL QUESTIONS (SNIPPETS )

-Vishal Vanaki

Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ? A.rem = 3.14 % 2.1; B.rem = modf(3.14, 2.1); C.rem = fmod(3.14, 2.1); D.Remainder cannot be obtain in floating point division.

How would you round off a value from 1.66 to 2.0? A.ceil(1.66) B.floor(1.66) C.roundup(1.66) D.roundto(1.66)

By default a real number is treated as a A.float B.double C.long double D.far double

C data types classification are Primary data types

int char float double void Array Pointer Structure Union Enum

Secondary data types (or) User-defined data type


main( ) { int const * p=5; printf("%d",++(*p)); }

Consider the following lines of C code :


int i,j,summ,lim; i=0; j=1; for(lim = 1; lim <= 10; lim++) { summ = j + i; i = j; j = sum; printf("%d",summ); }

Which of the following is the correct order of evaluation for the below expression?
z=x+y*z/4%2-1 A.* / % + - = B.= * / % + C./ * % - + = D.* % / - + =

What will you do to treat the constant 3.14 as a long double? A.use 3.14LD B.use 3.14L C.use 3.14DL D.use 3.14LF

How many times the program will print "IndiaBIX" ? #include<stdio.h> int main() { printf("IndiaBIX"); main(); return 0; } A.Infinite times B.32767 times C.65535 times D.Till stack doesn't overflow

Specify the 2 library functions to dynamically allocate memory? A.malloc() and memalloc() B.alloc() and memalloc() C.malloc() and calloc() D.memalloc() and faralloc()

What will be the output of the program? int main() { int i=0; for(; i<=5; i++); printf("%d,", i); return 0; } A.0, 1, 2, 3, 4, 5 B.5 C.1, 2, 3, 4 D.6

#include<stdio.h> int main() { int a = 500, b = 100, c; if(!a >= 400) b = 300; c = 200; printf("b = %d c = %d\n", b, c); return 0;} A.b = 300 c = 200 B.b = 100 c = garbage C.b = 300 c = garbage D.b = 100 c = 200

#include<stdio.h> int main() { int x = 3; float y = 3.0; if(x == y) printf("x and y are equal"); else printf("x and y are not equal"); return 0; } A.x and y are equal B.x and y are not equal C.Unpredictable D.No output

#include<stdio.h> int main() { int i=4; switch(i) { default: printf("This is default\n"); case 1: printf("This is case 1\n"); break; case 2: printf("This is case 2\n"); break; case 3: printf("This is case 3\n"); } return 0; }

main() { int x=20,y=35; x=y++ + x++; y= ++y + ++x; printf(%d%dn,x,y); }

main() { int x=5; printf(%d,%d,%dn,x,x< <2,x>>2); }

#define swap(a,b) a=a+b;b=a-b;a=a-b; void main() { int x=5, y=10; swap (x,y); printf(%d %dn,x,y); swap2(x,y); printf(%d %dn,x,y); } int swap2(int a, int b) { int temp; temp=a; b=a; a=temp; return 0; }

main() { char *ptr = Cisco Systems; *ptr++; printf(%sn,ptr); ptr++; printf(%sn,ptr); }

main() { char s1[]=Cisco Sytems; printf(%s,s1); }

main() { int x=10, y=15; x = x++; y = ++y; printf(%d %dn,x,y); }

main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }

main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }

main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }

main() { printf("%x",-1<<4); }

main() { int c=- -2; printf("c=%d",c); }

main() { int i=10; i=!i>14; printf("i=%d",i); }

#includestdio.h main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%c",++*p + ++*str1-32); }

main() { printf("\nab"); printf("\bsi"); printf("\rha"); }

main() { int i=5; printf("%d%d%d%d%d%d",++i,i--,++i,--i,i); }

#define square(x) x*x main() { int i; i = 64/square(4); printf("%d",i); }

void main () { int i = 0 , a[3] ; a[i] = i++; printf (%d",a[i]) ; }

int x = 3000, y = 2000 ; long int z = x * y ;

char str[ ] = "Hello" ; strcat ( str, '!' ) ;

What is difference between memcmp() and memicmp()?


memcmp(arr1,arr2,sizeof(arr1)); Memicmp(arr1,arr2,sizeof(arr1));

void main( ) { unsigned int i=10; while (i>=0) { printf(%u,i); i--; } } How many times will the program execute? A.10 B. infinite C.9 D.3

void main() { int i =1, j =1; for (;j; printf(%d%d,)) j=j++<=5; } A.111111 B.111110 C.123456 D. gives an error

# include <stdio.h> void main( ) { int i ; for(i=0;i<=10;i++, printf (%d,i)); } A.0 to 10 B.1 to 11 C. compile error D. run time error

main() {int i=0; switch(i) {case 0: i++; printf("%d..",i); case 1: printf("%d..",i); case 1: printf("%d..",i); }}

#include<stdio.h> void main() { printf(5+"Fascimile"); }

Which of the following is not provided by the compiler? A. Constructor B. Destructor C. Contructor with one parameter D. Assignment operator

Write a program to reverse each words in string?

main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }

main() { static int var = 5; printf("%d ",var--); if(var) main(); }

main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }

#includestdio.h #define a 10 main() { #define a 50 printf("%d",a); }

#define clrscr() 100 main() { clrscr(); printf("%d\n",clrscr()); }

main() { printf("%p",main); }

main() { incr(); incr(); incr(); } incr() { static int i; printf(%d,++i); }

main() { int i=123; printf(\1%d,i); }

main() { char x[10],*ptr=x; scanf(%s,x); change(&x[4]); } change(char a[]) {puts(a);} if abcdefg is input, the output will be

a two dimensional array A is declared as int A[4][2]={0}. What values would be printed after execution the following statement? printf(%d,sizeof(A));

int x=4,*y; y=&x;(*y)++; printf(%d,%d\n,*y);

main() { int i=400,j=300; printf("%d..%d"); }

main() { char *p; p="Hello"; printf("%c\n",*&*p); }

#define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); }

main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); }

main( ) { char *q; int j; for (j=0; j<3; j++) scanf("%s" ,(q+j)); for (j=0; j<3; j++) printf("%c" ,*(q+j)); for (j=0; j<3; j++) printf("%s" ,(q+j)); } Take i/p as MOUSE,TRACK,VIRTUAL

-Thank You

You might also like