C Interview Questions
Questions Answers Views Company eMail

main() {char a[10]={1,2,3,4,5,6};int x; for(x=0;x<4;x++){ b[x]=x+'a';} printf("%s",b);}

3 5520

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

Wipro, CitiGroup, Advent Global Solutions, Valeo Lighting Systems India Private Limited, Vishal Transformers, Zencer,

26 50396

main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); }

CitiGroup,

4 6335




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

CitiGroup, College School Exams Tests, CISOC,

11 20705

main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%s\n",ptr); ptr++; printf("%s\n",ptr); } Find the Outputs?

CitiGroup, BTBP,

9 10368

#include main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } Find the output

CitiGroup,

5 7649

f(char *p) { p=(char *)malloc(sizeof(6)); strcpy(p,"HELLO"); } main() { char *p="BYE"; f(p) printf("%s",p); } what is the output?

Hughes, Tech Mahindra,

9 8643

Result of the following program is 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

IBM,

8 14410




What is the result main() { char c=-64; int i=-32 unsigned int u =-16; if(c>i){ printf("pass1,"); if(c

IBM,

9 8165

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 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

IBM,

1 4476

In the following code segment what will be the result of the function, value of x , value of y { 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

IBM,

1 4902

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

IBM,

2 3964

What will be result of the following program? void myalloc(char *x, int n) { x= (char *)malloc(n*sizeof(char)); memset(x,\0,n*sizeof(char)); } main() { char *g="String"; myalloc(g,20); strcpy(g,"Oldstring"); printf("The string is %s",g); } a) The string is : String b) Run time error/Core dump c) The string is : Oldstring d) Syntax error during compilation e) None of these

IBM,

3 4889

What will be the result of the following program? main() { char p[]="String"; int x=0; if(p=="String") { printf("Pass 1"); if(p[sizeof(p)-2]=='g') printf("Pass 2"); else printf("Fail 2"); } else { printf("Fail 1"); if(p[sizeof(p)-2]=='g') printf("Pass 2"); else printf("Fail 2"); } } a) Pass 1, Pass 2 b) Fail 1, Fail 2 c) Pass 1, Fail 2 d) Fail 1, Pass 2 e) syntax error during compilation

IBM,

10 6875

Struct(s) { int a; long b; } Union (u) {int a; long b; } Print sizeof(s)and sizeof(u) if sizeof(int)=4 and sizeof(long)=4

Mascot,

2 3642


Post New C Questions






Un-Answered Questions { C }

write a program in c language to print your bio-data on the screen by using functions.

5421


what is the diffrenet bettwen HTTP and internet protocol

705


WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER

792


what are bit fields? What is the use of bit fields in a structure declaration?

786


hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..

720






if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

3345


Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.

1899


how to create duplicate link list using C???

1297


find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }

1094


write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)

869


In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)

853


In which layer of the network datastructure format change is done

547


write a programming in c to find the sum of all elements in an array through function.

986


program for reversing a selected line word by word when multiple lines are given without using strrev

1219


You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.

1041