My Profile
Active Members
TodayLast 7 Days
more...
Awards & Gifts
Online Exams
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian
cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
Paid Surveys
|
C Interview Questions
Posted Date: 23 Apr 2008 Resource Type: Articles/Knowledge Sharing Category: Jobs & Interviews
|
Posted By: vijay kumar Member Level: Diamond Rating: Points: 3
|
|
|
|
1.What is C language?
2.printf() Function What is the output of printf("%d")?
3.malloc() Function- What is the difference between "calloc(...)" and "malloc(...)"
4.rintf() Function- What is the difference between "printf(...)" and "sprintf(...)
5.Compilation How to reduce a final size of executable?
6.Linked Lists -- Can you tell me how to check whether a linked list is circular?
7."union" Data Type What is the output of the following program? Why?
8.String Processing --- Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba.
9.What will print out? main() { char *p1=“name”; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20); while(*p2++ = *p1++); printf(“%s\n”,p2); } The pointer p2 value is also increasing with p1 . *p2++ = *p1++ means copy value of *p1 to *p2 , then increment both addresses (p1,p2) by one , so that they can point to next address . So when the loop exits (ie when address p1 reaches next character to “name” ie null) p2 address also points to next location to “name” . When we try to print string with p2 as starting address , it will try to print string from location after “name” … hence it is null string ….
e.g. : initially p1 = 2000 (address) , p2 = 3000 *p1 has value “n” ..after 4 increments , loop exits … at that time p1 value will be 2004 , p2 =3004 … the actual result is stored in 3000 - n , 3001 - a , 3002 - m , 3003 -e … we r trying to print from 3004 …. where no data is present … that's why its printing null .
10.What will be printed as the result of the operation below: main() { int x=20,y=35; x=y++ + x++; y= ++y + ++x; printf(“%d%d\n”,x,y) ; }
11.What will be printed as the result of the operation below: main() { int x=5; printf(“%d,%d,%d\n”,x,x<<2,>>2) ; }
12.What will be printed as the result of the operation below: #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 %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 0; } as x = 5 = 0×0000,0101; so x << 2 -< 0×0001,0100 = 20; x >7gt; 2 -> 0×0000,0001 = 1. Therefore, the answer is 5, 20 , 1
12.What will be printed as the result of the operation below: main() { char *ptr = ” Tech Preparation”; *ptr++; printf(“%s\n”,ptr) ; ptr++; printf(“%s\n”,ptr);
} 1) ptr++ increments the ptr address to point to the next address. In the previous example, ptr was pointing to the space in the string before C, now it will point to C.
2)*ptr++ gets the value at ptr++, the ptr is indirectly forwarded by one in this case.
3)(*ptr)++ actually increments the value in the ptr location. If *ptr contains a space, then (*ptr)++ will now contain an exclamation mark.
13.What will be printed as the result of the operation below:
main() { char s1[]=“Tech”; char s2[]= “preparation”; printf(“%s”,s1) ; }
14.What will be printed as the result of the operation below: main() { char *p1; char *p2;
p1=(char *)malloc(25); p2=(char *)malloc(25);
strcpy(p1,”Tech”); strcpy(p2,“preparation”); strcat(p1,p2);
printf(“%s”,p1) ; }
15.The following variable is available in file1.c, who can access it?: static int average;
16.What will be the result of the following code? #define TRUE 0 // some code while(TRUE) { // some code
17.What will be printed as the result of the operation below: int x; int modifyvalue() { return(x+=10); }
int changevalue(int x) { return(x+=1); }
void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x);
x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x);
}
18.What will be printed as the result of the operation below: main() { int x=10, y=15; x = x++; y = ++y; printf(“%d %d\n”,x,y);
}
19.What will be printed as the result of the operation below: main() { int a=0; if(a==0) printf(“Tech Preparation\n”); printf(“Tech Preparation\n”);
}
20.What will the following piece of code do int f(unsigned int x) { int i; for (i=0; x!0; x>>=1){ if (x & 0X1) i++; } return i; }
21.What will happen in these three cases?
22.What are x, y, y, u #define Atype int* typedef int *p; p x, z; Atype y, u;
23.What does static variable mean?
24.Advantages of a macro over a function?
25.What are the differences between malloc() and calloc()?
26.What are the different storage classes in C?
27.What is the difference between strings and character arrays?
28.Write down the equivalent pointer expression for referring the same element a[i][j][k][l]
29.Which bit wise operator is suitable for checking whether a particular bit is on or off
30.Which bit wise operator is suitable for turning off a particular bit in a number?
|
Responses
|
No responses found. Be the first to respond and make money from revenue sharing program.
|
|
|