C Interview Questions and Answers -TCS
-
Upload
venki-inn-confusion -
Category
Documents
-
view
221 -
download
1
Transcript of C Interview Questions and Answers -TCS
-
8/13/2019 C Interview Questions and Answers -TCS
1/35
C Language Function
Interview Answers Sample
C program ex amples
C interview questions and answers
Data type questions
Variable naming rule questions
Operators questions
Control flow questions
Switch case questions
Looping questions
Pointer questions
String questions
Printf,Scanf questions
Preprocessor questions
Structure questions
Commad line argument
C questions in Linux
C online test
C mixed practice sets
C tricky questions
Example of recursion in c
C programming forums
C QUESTIONS AND ANSWERS
Memory mapping tutorial in c
Variables tutorial in c
Data types tutorial in c
Storage cla sses tutorial in c
Looping tutorial in c
Pointers tutorial in c
C TUTORIAL
26Share More Next Blog
http://cquestions.com/2010/02/looping-in-c.htmlhttp://www.blogger.com/next-blog?navBar=true&blogID=959939550345671470http://www.blogger.com/http://www.blogger.com/next-blog?navBar=true&blogID=959939550345671470http://c-pointer.blogspot.com/http://cquestions.com/2010/02/looping-in-c.htmlhttp://cquestions.com/2011/02/storage-classes-in-c-with-examples.htmlhttp://cquestions.com/2011/02/data-types-in-c-language.htmlhttp://cquestions.com/2009/10/definition-of-variable-in-c.htmlhttp://cquestions.com/2011/02/memory-mapping-in-c.htmlhttp://cquestions.com/2010/09/c-programming-forums_25.htmlhttp://cquestions.com/2011/08/example-of-recursion-in-c-programming.htmlhttp://cquestions.com/2012/02/tricky-c-questions-and-answers.htmlhttp://cquestions.com/2010/04/c-questions-answers.htmlhttp://cquestions.com/2010/03/c-free-online-test.htmlhttp://cquestions.com/2012/02/c-linux-interview-questions-and-answers.htmlhttp://cquestions.com/2008/09/command-line-argument-questions-with.htmlhttp://cquestions.com/2009/09/structure-questions-with-explanation-in.htmlhttp://cquestions.com/2012/02/c-preprocessor-questions-and-answers.htmlhttp://cquestions.com/2009/01/printf-function-questions-and-answer.htmlhttp://cquestions.com/2012/02/c-string-questions-and-answers-with.htmlhttp://cquestions.com/2012/02/c-pointers-questions.htmlhttp://cquestions.com/2012/02/looping-questions-in-c-and-answers.htmlhttp://cquestions.com/2010/06/technical-questions-in-c.htmlhttp://cquestions.com/2010/01/if-else-questions-in-c.htmlhttp://cquestions.com/2012/02/c-operator-questions-with-answers.htmlhttp://cquestions.com/2010/06/variable-naming-rule-questions-in-c.htmlhttp://cquestions.com/2012/02/data-type-questions-in-c.htmlhttp://cquestions.com/2010/10/c-interview-questions-and-answers.htmlhttp://cquestions.com/2010/07/c-program-examples.htmlhttp://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-0153514538688941&output=html&h=90&slotname=4134590364&adk=612826838&w=200&lmt=1379965006&host=pub-1556223355139109&flash=11.8.800&url=http%3A%2F%2Fwww.cquestions.com%2F2010%2F10%2Fc-interview-questions-and-answers.html&dt=1379986201851&bpp=8&bdt=5051&shv=r20130917&cbv=r20130906&saldr=sa&prev_slotnames=6465271747%2C9780378087%2C7530551827%2C8451121234%2C5040997581&correlator=1379986200946&frm=20&ga_vid=1576325231.1379986201&ga_sid=1379986201&ga_hid=1510954612&ga_fc=1&u_tz=330&u_his=1&u_java=1&u_h=768&u_w=1366&u_ah=728&u_aw=1366&u_cd=32&u_nplug=7&u_nmime=16&dff=arial&dfs=14&adx=115&ady=502&biw=1349&bih=667&oid=3&ref=https%3A%2F%2Fwww.google.co.in%2F&vis=2&fu=0&ifi=6&dtd=20&xpc=fwGvu7gUw6&p=http%3A//www.cquestions.com&rl_rc=true&adsense_enabled=true&ad_type=text&ui=rc:0&oe=UTF8&height=90&width=200&format=fpkc_al_lp&kw_type=radlink&prev_fmts=200x90_0ads_al&rt=ChBSQOsZAAqPagrirQtHAB9YEhlJbnRlcnZpZXcgQW5zd2VycyBTYW1wbGVzGgjjmYIfa-JSoigBMANSEwi8odqa8eK5AhUhnOIKHQJTAJU&hl=en&kw0=C+Language&kw1=Function&kw2=Interview+Answers+Samples&okw=Interview+Answers+Sampleshttp://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-0153514538688941&output=html&h=90&slotname=4134590364&adk=612826838&w=200&lmt=1379965006&host=pub-1556223355139109&flash=11.8.800&url=http%3A%2F%2Fwww.cquestions.com%2F2010%2F10%2Fc-interview-questions-and-answers.html&dt=1379986201851&bpp=8&bdt=5051&shv=r20130917&cbv=r20130906&saldr=sa&prev_slotnames=6465271747%2C9780378087%2C7530551827%2C8451121234%2C5040997581&correlator=1379986200946&frm=20&ga_vid=1576325231.1379986201&ga_sid=1379986201&ga_hid=1510954612&ga_fc=1&u_tz=330&u_his=1&u_java=1&u_h=768&u_w=1366&u_ah=728&u_aw=1366&u_cd=32&u_nplug=7&u_nmime=16&dff=arial&dfs=14&adx=115&ady=502&biw=1349&bih=667&oid=3&ref=https%3A%2F%2Fwww.google.co.in%2F&vis=2&fu=0&ifi=6&dtd=20&xpc=fwGvu7gUw6&p=http%3A//www.cquestions.com&rl_rc=true&adsense_enabled=true&ad_type=text&ui=rc:0&oe=UTF8&height=90&width=200&format=fpkc_al_lp&kw_type=radlink&prev_fmts=200x90_0ads_al&rt=ChBSQOsZAAqPZwrirQtHAB9YEghGdW5jdGlvbhoIQIGLVi-jxakoATADUhMIvKHamvHiuQIVIZziCh0CUwCV&hl=en&kw0=C+Language&kw1=Function&kw2=Interview+Answers+Samples&okw=Functionhttp://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-0153514538688941&output=html&h=90&slotname=4134590364&adk=612826838&w=200&lmt=1379965006&host=pub-1556223355139109&flash=11.8.800&url=http%3A%2F%2Fwww.cquestions.com%2F2010%2F10%2Fc-interview-questions-and-answers.html&dt=1379986201851&bpp=8&bdt=5051&shv=r20130917&cbv=r20130906&saldr=sa&prev_slotnames=6465271747%2C9780378087%2C7530551827%2C8451121234%2C5040997581&correlator=1379986200946&frm=20&ga_vid=1576325231.1379986201&ga_sid=1379986201&ga_hid=1510954612&ga_fc=1&u_tz=330&u_his=1&u_java=1&u_h=768&u_w=1366&u_ah=728&u_aw=1366&u_cd=32&u_nplug=7&u_nmime=16&dff=arial&dfs=14&adx=115&ady=502&biw=1349&bih=667&oid=3&ref=https%3A%2F%2Fwww.google.co.in%2F&vis=2&fu=0&ifi=6&dtd=20&xpc=fwGvu7gUw6&p=http%3A//www.cquestions.com&rl_rc=true&adsense_enabled=true&ad_type=text&ui=rc:0&oe=UTF8&height=90&width=200&format=fpkc_al_lp&kw_type=radlink&prev_fmts=200x90_0ads_al&rt=ChBSQOsZAAqPUgrirQtHAB9YEgpDIExhbmd1YWdlGgj3u7h3_gkCyigBMANSEwi8odqa8eK5AhUhnOIKHQJTAJU&hl=en&kw0=C+Language&kw1=Function&kw2=Interview+Answers+Samples&okw=C+Languagehttp://www.google.com/url?ct=abg&q=https://www.google.com/adsense/support/bin/request.py%3Fcontact%3Dabg_afc%26url%3Dhttp://www.cquestions.com/2010/10/c-interview-questions-and-answers.html%26gl%3DIN%26hl%3Den%26client%3Dca-pub-0153514538688941&usg=AFQjCNF15w6Khm823T9VeJG6GcU43TR8oA -
8/13/2019 C Interview Questions and Answers -TCS
2/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 2/35
}
}
Solution: 3
void main(){
switch(printf("Hello world")){
}
}
Hide
2
Swap two variables without using third variable.
Explanation:
#include
intmain(){
inta=5,b=10;
//process one a=b+a;
b=a-b;
a=a-b;
printf("a= %d b= %d",a,b);
//process two
a=5;
b=10;
a=a+b-(b=a);
printf("\na= %d b= %d",a,b);
//process three
a=5;
b=10;
a=a^b;
b=a^b;
a=b^a;
printf("\na= %d b= %d",a,b);
//process four
a=5;
b=10;
a=b-~a-1;
b=a+~b+1; a=a+~b+1;
printf("\na= %d b= %d",a,b);
//process five
a=5,
b=10;
a=b+a,b=a-b,a=a-b;
printf("\na= %d b= %d",a,b);
return 0;}
Hide
3
What is dangling pointer in c?
Function tutorial in c
Array tutorial in c
Preprocessor tutorial in c
Advanced c tutorial
SWAP TWO VARIABLES WITHOUTUSING THIRD USING C PROGRAMVARIABLE
C program examples
Check given number is primenumber or not using c program
C interview questions and answers
Program to convert decimal to binaryin c
Write a c program to reverse a string
TO FIND FIBONACCI SERIES USINGC PROGRAM
QUICK SORT USING C PROGRAM
Find out the perfect number using cprogram
Merge sort program in c
POPULAR POSTS
Enter your email address:
Subscribe
Delivered by FeedBurner
SUBSCRIBE VIA EMAIL
C questions and answers
Debugging questions in c with
answers
Aptitude questions and answers in c
C basic questions
Multiple choice questions in c
C PROGRAMMING QUESTIONS AND ANSWER
Excellent
GoodAvg
Worst
Vote Show results
Votes s o far: 5764
Days left to vote: 810
STANDARD OF QUESTIONS ?
C programming questions and answer
C questions and answers
Debugging questions in c withanswers
Aptitude questions and answers in c
C basic questions
Multiple choice questions in c
Objective questions of c
Program in c language
Simple program example in c
MY HEADLINES
http://www.cquestions.com/2012/05/debugging-questions-in-c-with-answers.htmlhttp://www.cquestions.com/2012/05/simple-program-in-c-language.htmlhttp://www.cquestions.com/2012/05/program-in-c-language.htmlhttp://www.cquestions.com/2012/05/objective-questions-of-c.htmlhttp://www.cquestions.com/2012/05/multiple-choice-questions-in-c.htmlhttp://www.cquestions.com/2012/05/c-basic-questions.htmlhttp://www.cquestions.com/2012/05/aptitude-questions-and-answers-in-c.htmlhttp://www.cquestions.com/2012/05/debugging-questions-in-c-with-answers.htmlhttp://www.cquestions.com/2012/02/c-questions-and-answers.htmlhttp://www.cquestions.com/http://www.google.com/reviews/polls/display/7608202716729500181/blogger_template/result?hideq=true&purl=www.cquestions.com&font=normal+normal+14px+Arial,+Tahoma,+Helvetica,+FreeSans,+sans-serif&lnkclr=%2311593c&chrtclr=%2311593c&txtclr=%23222http://feedproxy.google.com/~r/blogspot/mddYU/~3/jVoMEN2NqR0/multiple-choice-questions-in-c.htmlhttp://feedproxy.google.com/~r/blogspot/mddYU/~3/vla4TTc_VA8/c-basic-questions.htmlhttp://feedproxy.google.com/~r/blogspot/mddYU/~3/a9oc0I21TVE/aptitude-questions-and-answers-in-c.htmlhttp://feedproxy.google.com/~r/blogspot/mddYU/~3/FNE4FvW9134/debugging-questions-in-c-with-answers.htmlhttp://feedproxy.google.com/~r/blogspot/mddYU/~3/CcEvvyASftA/c-questions-and-answers.htmlhttp://feedburner.google.com/http://www.cquestions.com/2011/07/merge-sort-program-in-c.htmlhttp://www.cquestions.com/2008/01/write-c-program-to-find-perfect-number.htmlhttp://www.cquestions.com/2008/01/c-program-for-quick-sort.htmlhttp://www.cquestions.com/2008/01/write-c-program-to-find-fibonacci.htmlhttp://www.cquestions.com/2010/08/write-c-program-to-reverse-string.htmlhttp://www.cquestions.com/2011/07/program-to-convert-decimal-to-binary-in.htmlhttp://www.cquestions.com/2010/10/c-interview-questions-and-answers.htmlhttp://www.cquestions.com/2012/02/check-given-number-is-prime-number-or.htmlhttp://www.cquestions.com/2010/07/c-program-examples.htmlhttp://www.cquestions.com/2008/01/write-c-program-for-swap-two-variables.htmlhttp://cquestions.com/2011/07/advanced-c-tutorial.htmlhttp://cquestions.com/2011/01/preprocessor-in-c.htmlhttp://cquestions.com/2010/02/array-in-c.htmlhttp://cquestions.com/2009/09/function-tutorial-in-c.htmlhttp://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink2http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink1 -
8/13/2019 C Interview Questions and Answers -TCS
3/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 3/35
Explanation:
Dangling pointer:
If any pointer is pointing the memory address of any var
after some variable has deleted from that
location while pointer is still pointing such memory locat
pointer is known as dangling pointer and this problem is
dangling pointer problem.
Initially:
Later:
For example:
What will be output of following c program?
#include
int*call();
intmain(){
int*ptr;
ptr=call();
fflush(stdin);
printf("%d",*ptr);
return 0;}
int* call(){
intx=25;
++x;
return&x;
}
Output: Garbage value
Note: In some compiler you may get warning message returning
of local variable or temporary
Explanation: variable x is local variable. Its scope and lif
within the function call hence after returning address of x
x became dead and pointer is still pointing ptr is still poi
language
Tricky c questions and answers
C programming online test
C Linux interview questions andanswers
Looping questions in c and answers
C string questions and answers withexplanation
C operator questions with answers
Check the given number is
palindrome number or not using c
programC pointers questions
Data type questions in c
Check given number is primenumber or not using c program
struct bit fields questions in c
C questions answers
C interview questions and answers
How to test palindrome in c++
Palindrome number in c++
Program of palindrome number inc++
C++ code to get sum of all odd
numbers in given range
Join this site
w ith Google Friend Connect
Members (2718) More
Already a member? Sign in
C LOVER COMMUNITY
ritesh kumar
1.4kFollow
View my complete
profile
ABOUT ME
Add to circles
GOOGLE+ BADGE
http://www.cquestions.com/2012/05/simple-program-in-c-language.htmlhttps://plus.google.com/107613622257143058549?prsrc=2https://plus.google.com/107613622257143058549https://plus.google.com/107613622257143058549http://feedburner.google.com/http://www.cquestions.com/2011/12/c-code-to-get-sum-of-all-odd-numbers-in.htmlhttp://www.cquestions.com/2011/12/program-of-palindrome-number-in-c.htmlhttp://www.cquestions.com/2011/12/palindrome-number-in-c.htmlhttp://www.cquestions.com/2011/12/how-to-test-palindrome-in-c.htmlhttp://www.cquestions.com/2010/10/c-interview-questions-and-answers.htmlhttp://www.cquestions.com/2010/04/c-questions-answers.htmlhttp://www.cquestions.com/2012/01/struct-bit-fields-questions-in-c.htmlhttp://www.cquestions.com/2012/02/check-given-number-is-prime-number-or.htmlhttp://www.cquestions.com/2012/02/data-type-questions-in-c.htmlhttp://www.cquestions.com/2012/02/c-pointers-questions.htmlhttp://www.cquestions.com/2012/02/check-given-number-is-palindrome-number.htmlhttp://www.cquestions.com/2012/02/c-operator-questions-with-answers.htmlhttp://www.cquestions.com/2012/02/c-string-questions-and-answers-with.htmlhttp://www.cquestions.com/2012/02/looping-questions-in-c-and-answers.htmlhttp://www.cquestions.com/2012/02/c-linux-interview-questions-and-answers.htmlhttp://www.cquestions.com/2012/02/c-programming-online-test.htmlhttp://www.cquestions.com/2012/02/tricky-c-questions-and-answers.htmlhttp://www.cquestions.com/2012/05/simple-program-in-c-language.htmlhttp://3.bp.blogspot.com/-g1bIfHbAc4A/TtfsqbeqrRI/AAAAAAAABh8/QZKTjIs9VwE/s1600/Concept9.jpeghttp://2.bp.blogspot.com/-K4VglR8co6o/Ttfspv2RvgI/AAAAAAAABh0/6xQLHxUseko/s1600/Concept8.jpeg -
8/13/2019 C Interview Questions and Answers -TCS
4/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 4/35
that location.
Solution of this problem:
Make the variable x is as static variable. In other word we
pointer whose pointing object has been deleted is called dan
pointer.
#include
int*call();
intmain(){
int*ptr;
ptr=call();
fflush(stdin);
printf("%d",*ptr);
return 0;
}
int* call(){
static intx=25;++x;
return&x;
}
Output: 26
Hide
4
What is wild pointer in c?
Explanation:
A pointer in c which has not been initialized is knownpointer.
Example:
What will be output of following c program?
intmain(){int*ptr;printf("%u\n",ptr);printf("%d",*ptr);return 0;
}
Output:Any addressGarbage value
Here ptr is wild pointer because it has not been initializis difference between the NULL pointer and wild pointer. Nupoints the base address of segment whilewild pointer doesany specific memory location.
Hide
5
What are merits and demerits of array in c?
Explanation:
http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink4http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink3 -
8/13/2019 C Interview Questions and Answers -TCS
5/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 5/35
Merits:
(a) We can easily access each element of array.
(b) Not necessity to declare too many variables.
(c) Array elements are stored in continuous memory location.
Demerit:
(a) Wastage of memory space. We cannot change size of arr
run time.
(b) It can store only similar type of data.
Hide
6Do you know memory representation of inta = 7 ?
Explanation:
Memory representation of:
signed int a=7; (In Turbo c compiler)
signed short int a=7 (Both turbo c and Linux gcc compiler)
Binary equivalent of data 7 in 16 bit: 00000000 00000111
Data bit: 0000000 00000111 (Take first 15 bit form right sid
Sign bit: 0 (Take leftmost one bit)
First eight bit of data bit from right side i.e. 00000111 w
in the leftmost byte from right to left side and rest sev
data bit i.e. 0000000 will store in rightmost byte from rig
side as shown in the following figure:
7What is and why array in c?
Explanation:An array is derived data type in c programming language
store similar type of data in continuous memory location. Da
primitive type (int, char, float, double), address o
structure, pointer, function or another array.
Example of array declaration:
intarr[5];
chararr[5];
floatarr[5];
longdoublearr[5];
char* arr[5];int(arr[])();
double** arr[5];
Array is useful when:
http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink5http://4.bp.blogspot.com/-q99tgJBzfMA/TtfshSrczVI/AAAAAAAABgo/4eC_3DMO-rw/s1600/24.jpeg -
8/13/2019 C Interview Questions and Answers -TCS
6/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 6/35
(a) We have to store large number of data of similar type. I
large number of similar kind of variable then it is very dif
remember name of all variables and write the program. For ex
//PROCESS ONE
intmain(){
intax=1;
intb=2;
intcg=5;
intdff=7;
intam=8;
intraja=0;
intrani=11;
intxxx=5;
intyyy=90;
intp;
intq;
intr;
intavg;
avg=(ax+b+cg+dff+am+raja+rani+xxx+yyy+p+q+r)/12;
printf("%d",avg); return 0;
}
If we will use array then above program can be written as:
//PROCESS TWO
intmain(){
intarr[]={1,2,5,7,8,0,11,5,50};
inti,avg;
for(inti=0;i
-
8/13/2019 C Interview Questions and Answers -TCS
7/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 7/35
Array of pointers in c:
Array whose content is address of another variable is known
pointers. For example:
intmain(){
floata=0.0f,b=1.0f,c=2.0f;
float* arr[]={&a,&b,&c};
b=a+c;
printf("%f",arr[1]);
return 0;
}
Hide
8
Why we use do-while loop in c? Also tell any properties whic
Explanation:
It is also called as post tested loop. It is used wh
necessary to execute the loop at least one time. Syntax:
do {
Loop body
} while (Expression);
Example:
intmain(){
intnum,i=0;
do{
printf("To enter press 1\n");
printf("To exit press 2");
scanf("%d",&num);
++i;
switch(num){
case1:printf("You are welcome\n");break;
default: exit(0);
} }
while(i
-
8/13/2019 C Interview Questions and Answers -TCS
8/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 8/35
return 0;
}
Output: 3 3 4 4
(b)
intmain(){
doublei=5.63333;
do
printf("hi");
while(!i);
return 0;
}
Output: hi
(c)
intmain(){
intx=25,y=1;
do
if(x>5) printf(" ONE");
elseif(x>10)
printf(" TWO");
elseif(x==25)
printf(" THREE");
else
printf(" FOUR");
while(y--);
return 0;
}
Output: ONE ONE
Hide
9
What is the meaning of prototype of a function?
Explanation:
Prototype of a function
Declaration of function is known as prototype of a
Prototype of a function means
(1) What is return type of function?
(2) What parameters are we passing?
(3) For example prototype of printf function is:
intprintf(constchar*, );
I.e. its return type is int data type, its first parameter
character pointer and second parameter is ellipsis i.e.
number of arguments.
Hide
http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink9http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink8 -
8/13/2019 C Interview Questions and Answers -TCS
9/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 9/35
10
Write a c program to modify the constant variable in c?
Explanation:
You can modify constant variable with the help of poin
example:
#include
intmain(){
inti=10;
int*ptr=&i;
*ptr=(int*)20;
printf("%d",i);
return 0;
}
Output: 20
Hide
11
What is pointer to a function?
Explanation:
(1) What will be output if you will execute following code?int* function();intmain(){
autoint*x;int*(*ptr)();ptr=&function;x=(*ptr)();printf("%d",*x);
}int*function(){
staticinta=10;return&a;
}
Output: 10Explanation: Here function is function whose parameter istype and return type is pointer to int data type.
x=(*ptr)()=> x=(*&functyion)() //ptr=&function=> x=function() //From rule *&p=p=> x=&aSo, *x = *&a = a =10
(2) What will be output if you will execute following code?
intfind(char);int(*function())(char);intmain(){
intx;int(*ptr)(char);ptr=function();x=(*ptr)('A');printf("%d",x);return 0;
}intfind(charc){
returnc;}int(*function())(char){
returnfind;}
Output: 65Explanation: Here function whose name is function which pasdata type and returning another function whose parameter istype and return type is int data type.
http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink10 -
8/13/2019 C Interview Questions and Answers -TCS
10/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 10/35
x=(*ptr)(A)=> x= (*function ()) (A) //ptr=function ()//&find=function () i.e. return type of function ()=> x= (* &find) (A)=> x= find (A) //From rule*&p=p=> x= 65
(3) What will be output if you will execute following code?
char* call(int*,float*);int main(){
char*string;inta=2;floatb=2.0l;char*(*ptr)(int*,float*);ptr=&call;string=(*ptr)(&a,&b);printf("%s",string);return 0;
}char*call(int*i,float*j){
static char*str="c-pointer.blogspot.com";str=str+*i+(int)(*j);returnstr;
}
Output: inter.blogspot.comExplanation: Here call is function whose return type is p
characterand one parameter is pointer to int data type aparameter is pointer to float data type and ptr is pointefunction.str= str+*i+ (int) (*j)=c-pointer.blogspot.com + *&a+ (int) (*&b)//i=&a, j=&b=c-pointer.blogspot.com + a+ (int) (b)=c-pointer.blogspot.com +2 + (int) (2.0)=c-pointer.blogspot.com +4=inter.blogspot.com
(4) What will be output if you will execute following code?
charfar * display(charfar*);int main(){
charfar* string="cquestionbank.blogspot.com";charfar *(*ptr)(charfar *);ptr=&display;string=(*ptr)(string);printf("%s",string);
}charfar *display(charfar * str){
charfar * temp=str;temp=temp+13;*temp='\0';returnstr;
}
Output: cquestionbakExplanation: Here display is function whose parameter is pcharacter and return type is also pointer to character and ppointer.
temp is char pointertemp=temp+13temp=\0
Above two lines replaces first dot character by null chastring of variable string i.e."cquestionbank\0blogspot.com"
As we know %s print the character of stream up to null chara
Hide
12
Write a c program to find size of structure without using siz
operator?
Explanation:
struct ABC{
http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink11 -
8/13/2019 C Interview Questions and Answers -TCS
11/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 11/35
inta;
floatb;
charc;
};
int main(){
structABC *ptr=(structABC *)0;
ptr++;
printf("Size of structure is: %d",*ptr);
return 0;
}
Hide
13
What is NULL pointer?
Explanation:
Literal meaning of NULL pointer is a pointer which is ponothing. NULL pointer points the base address of segment.
Examples of NULL pointer:
1. int*ptr=(char*)0;2. float*ptr=(float*)0;3. char*ptr=(char*)0;4. double*ptr=(double*)0;5. char*ptr=\0;6. int*ptr=NULL;
What is meaning of NULL?Answer:
NULL is macro constant which has been defined in the hstdio.h, alloc.h, mem.h, stddef.h and stdlib.h as#defineNULL 0
Examples:
(1)What will be output of following c program?
#include"stdio.h"int main(){
if(!NULL)printf("I know preprocessor");elseprintf("I don't know preprocessor");
}
Output: I know preprocessor
Explanation:!NULL = !0 = 1
In if condition any non zero number mean true.
(2)What will be output of following c program?
#include"stdio.h"int main(){
inti;staticintcount;for(i=NULL;i
-
8/13/2019 C Interview Questions and Answers -TCS
12/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 12/35
printf("%d",NULL+sizeof(NULL));}
Output: 2Explanation:NULL + sizeof(NULL)=0 + sizeoof(0)=0+2 //size of int data type is two byte.
We cannot copy anything in the NULL pointer.
Example:
(4)What will be output of following c program?
#include"string.h"int main(){
char*str=NULL;strcpy(str,"c-pointer.blogspot.com");printf("%s",str);return 0;
}
Output: (null)
Hide
14
What is difference between pass by value and pass by referenc
Explanation:
In c we can pass the parameters in a function in two differe
(a)Pass by value: In this approach we pass copy of actualin function as a parameter. Hence any modification oninside the function will not reflect in the actual variexample:
#include
int main(){ inta=5,b=10;
swap(a,b);
printf("%d %d",a,b);
return 0;
}
voidswap(inta,intb){
inttemp;
temp =a;
a=b;
b=temp;
}
Output: 5 10
(b)Pass by reference: In this approach we pass memory addrevariables in function as a parameter. Hence any modifiparameters inside the function will reflect in the actualFor example:
#incude
int main(){
inta=5,b=10;
swap(&a,&b);
printf("%d %d",a,b);
return 0;
}voidswap(int*a,int*b){
int *temp;
*temp =*a;
*a=*b;
*b=*temp;
http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink13 -
8/13/2019 C Interview Questions and Answers -TCS
13/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 13/35
}
Output: 10 5
Hide
15
What is size of void pointer?
Explanation:
Size of any type of pointer in c is independent of data type
pointer is pointing i.e. size of all type of pointer (near
two byte either it is char pointer, double pointer, functio
or null pointer. Void pointer is not exception of this rule
of void pointer is also two byte.
Hide
16
What is difference between uninitialized pointer and null poi
Explanation:
An uninitialized pointer is a pointer which points unknolocation while null pointer is pointer which points a nullbase address of segment. For example:
int*p; //Uninitialized pointer
int*q= (int*)0; //Null pointer
#include
int*r=NULL; //Null pointer
What will be output of following c program?
#include
#include
int main(){
char*p; //Uninitialized pointer
char*q=NULL; //Null pointer;
strcpy(p,"cquestionbank");
strcpy(q,"cquestionbank");
printf("%s %s",p,q); return 0;
}
Output: cquestionbank (null)
Hide
17
Can you read complex pointer declaration?
Explanation:
Rule 1. Assign the priority to the pointer declaration cprecedence and associative according to following table.
http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink16http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink15http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink14 -
8/13/2019 C Interview Questions and Answers -TCS
14/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 14/35
(): This operator behaves as bracket operator or function op
[]: This operator behaves as array subscription operator.
*: This operator behaves as pointer operator not as multiplioperator.
Identifier: It is not an operator but it is name of pointerYou will always find the first priority will be assigned toof pointer.
Data type: It is also not an operator. Data types also inclu
modifier (like signed int, long double etc.)
You will understand it better by examples:
(1) How to read following pointer?
char (* ptr)[3]
Answer:Step 1: () and [] enjoys equal precedence. So rule of associwill decide the priority. Its associative is left to right spriority goes to ().
Step 2: Inside the bracket * and ptr enjoy equal precedence.rule of associative (right to left) first priority goes to psecond priority goes to *.
Step3: Assign third priority to [].
Step4: Since data type enjoys least priority so assign fourt
priority to char.
Now read it following manner:
ptris pointerto such one dimensional arrayof size three wcontent chartype data.
http://3.bp.blogspot.com/-8vcccBL3mxs/TtkcyHh9jpI/AAAAAAAABjs/Zd9KbiwNJso/s1600/complexa2.jpeghttp://3.bp.blogspot.com/-Kq2PDB1PLP0/TtkcygZM45I/AAAAAAAABj0/zK6obSY_7kY/s1600/complexa3.jpeghttp://4.bp.blogspot.com/-reWOgl16R2E/TtkczbwP_-I/AAAAAAAABj4/FZ_BGYHH2vM/s1600/complexa4.jpeghttp://4.bp.blogspot.com/-8ni_SqXDF6g/Ttkc1BkMUTI/AAAAAAAABkQ/AhjCBy-O-_8/s1600/precedance.jpeg -
8/13/2019 C Interview Questions and Answers -TCS
15/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 15/35
(2) How to read following pointer?
float (* ptr)(int)
Answer:Assign the priority considering precedence and associative.
Now read it following manner:ptris pointerto such functionwhose parameter is int typereturn type is floattype data.
Rule 2: Assign the priority of each function parameter separread it also separately. Understand it through following exa
(3) How to read following pointer?
void (*ptr)(int (*)[2],int (*) void))
Answer:
Assign the priority considering rule of precedence and assoc
Now read it following manner:
ptris pointerto such functionwhich first parameter is poione dimensional arrayof size two which contentinttype datasecond parameter is pointerto such functionwhich parameterand return type is int data type and return type is void.
(4) How to read following pointer?
int ( * ( * ptr ) [ 5 ] ) ( )
Answer:Assign the priority considering rule of precedence and assoc
Now read it following manner:
ptris pointerto such arrayof size five which contentare pointerto such functionwhich parameter is void and retis inttype data.
(5) How to read following pointer?
double*(*(*ptr)(int))(double **,char c)
http://1.bp.blogspot.com/-9nCHl8QA9ro/TtkcwC2-OlI/AAAAAAAABjc/rjtdqaoRHIA/s1600/complex7.jpeghttp://1.bp.blogspot.com/-qDgrADZcNoo/TtkctjFMeUI/AAAAAAAABjI/RbMxDrFcLn8/s1600/complex3.jpeghttp://3.bp.blogspot.com/-VxAaKFbfYYY/Ttkcso8R5OI/AAAAAAAABjA/1kG8T7xADG0/s1600/c2.jpeg -
8/13/2019 C Interview Questions and Answers -TCS
16/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 16/35
Answer:
Assign the priority considering rule of precedence and assoc
Now read it following manner:
ptris pointerto functionwhich parameter is int type data
return type is pointerto functionwhich first parameter is
to pointer of double data type and second parameter is char
type and return type ispointerto doubledata type.
(6) How to read following pointer?
unsigned **(*(*ptr)[8](char const *, ...)
Answer:Assign the priority considering rule of precedence and assoc
Now read it following manner:
ptris pointerto arrayof size eight and content of array
is pointerto functionwhich first parameter is pointer to cconstant and second parameter is variable number of argumentreturn type is pointerto pointerof unsignedint data type.
Hide
18
What are the parameter passing conventions in c?
Explanation:
1. pascal: In this style function name should (not necessaryuppercase .First parameter of function call is passed toparameter of function definition and so on.
2. cdecl: In this style function name can be both in the uor lower case. First parameter of function call is passed toparameter of function definition. It is default parameteconvention.
Examples:
1. What will be output of following program?
int main(){staticinta=25;voidcdecl conv1() ;voidpascal conv2();
conv1(a);conv2(a);return 0;;
}voidcdecl conv1(inta,intb){
printf("%d %d",a,b);}
http://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink17http://3.bp.blogspot.com/-JNJoqqLRF_Y/TtkcvdmfduI/AAAAAAAABjU/7Uo_QCpTm3g/s1600/complex6.jpeghttp://3.bp.blogspot.com/-vI0xHhu5td0/Ttkcuk6QEZI/AAAAAAAABjM/jkhqr2_sv08/s1600/complex5.jpeg -
8/13/2019 C Interview Questions and Answers -TCS
17/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 17/35
voidpascal conv2(inta,intb){
printf("\n%d %d",a,b);}
Output: 25 00 25
(2) What will be output of following program?
voidcdecl fun1(int,int);
voidpascal fun2(int,int);int main(){ inta=5,b=5;
fun1(a,++a); fun2(b,++b); return 0;}voidcdecl fun1(intp,intq){ printf("cdecl: %d %d \n",p,q);}voidpascal fun2(intp,intq){ printf("pascal: %d %d",p,q);}
Output:cdecl: 6 6pascal: 5 6
(3) What will be output of following program?
voidcdecl fun1(int,int);voidpascal fun2(int,int);int main(){ inta=5,b=5;
fun1(a,++a); fun2(b,++b); return 0;}voidcdecl fun1(intp,intq){ printf("cdecl: %d %d \n",p,q);}
voidpascal fun2(intp,intq){ printf("pascal: %d %d",p,q);}
Output:cdecl: 6 6pascal: 5 6
(4) What will be output of following program?
voidconvention(int,int,int);int main(){ inta=5;
convention(a,++a,a++); return 0;}void convention(intp,intq,intr){ printf("%d %d %d",p,q,r);}
Output: 7 7 5(5) What will be output of following program?
voidpascal convention(int,int,int);int main(){ inta=5;
convention(a,++a,a++); return 0;}voidpascal convention(intp,intq,intr){ printf("%d %d %d",p,q,r);}
Output: 5 6 6
(6) What will be output of following program?
voidpascal convention(int,int);int main(){ inta=1;
-
8/13/2019 C Interview Questions and Answers -TCS
18/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 18/35
convention(a,++a);
return 0;}voidpascal convention(inta,intb){ printf("%d %d",a,b);}
Output: 1 2
(7) What will be output of following program?
voidconvention(int,int);int main(){ inta=1;
convention(a,++a); return 0;}void convention(inta,intb){ printf("%d %d",a,b);}
Output: 2 2
Hide
19
What is the far pointer in c?
Explanation:
The pointer which can point or access whole the residenceRAM i.e. which can access all 16 segments is known as far po
Size of far pointer is 4 byte or 32 bit. Examples:
(1) What will be output of following c program?
int main(){intx=10;intfar *ptr;ptr=&x;printf("%d",sizeofptr);return 0;
}
Output: 4
(2)What will be output of following c program?
int main(){intfar *near*ptr;printf("%d %d",sizeof(ptr) ,sizeof(*ptr));return 0;
}
http://1.bp.blogspot.com/-h0BBu2UagTA/Ttkc0OTeR_I/AAAAAAAABkE/-hwwbTWc5Kk/s1600/Concept5.jpeghttp://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink18 -
8/13/2019 C Interview Questions and Answers -TCS
19/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 19/35
Output: 4 2Explanation: ptr is far pointer while *ptr is near pointer.
(3)What will be output of following c program?
int main(){intfar *p,far *q;printf("%d %d",sizeof(p) ,sizeof(q));
}
Output: 4 4
First 16 bit stores: Segment numberNext 16 bit stores: Offset address
Example:
int main(){intx=100;intfar *ptr;ptr=&x;printf("%Fp",ptr);return 0;
}
Output: 8FD8:FFF4Here 8FD8 is segment address and FFF4 is offset address inhexadecimal number format.
Note: %Fp is used for print offset and segment address of poprintf function in hexadecimal number format.In the header file dos.h there are three macro functions tooffset address and segment address from far pointer and vice
1. FP_OFF():To get offset address from far address.2. FP_SEG():To get segment address from far address.3. MK_FP():To make far address from segment and offset addr
Examples:(1)What will be output of following c program?
#include"dos.h"int main(){
inti=25;intfar*ptr=&i;printf("%X %X",FP_SEG(ptr),FP_OFF(ptr));
}
Output: Any segment and offset address in hexadecimal numberrespectively.
(2)What will be output of following c program?
#include"dos.h"int main(){
inti=25;intfar*ptr=&i;unsignedints,o;s=FP_SEG(ptr);o=FP_OFF(ptr);printf("%Fp",MK_FP(s,o));return 0;
}
Output: 8FD9:FFF4 (Assume)Note: Wecannot guess what will be offset address; segment a
and far address of any far pointer .These address are decideoperating system.
Limitation of far pointer:
We cannot change or modify the segment address of given farby applying any arithmetic operation on it. That is by using
-
8/13/2019 C Interview Questions and Answers -TCS
20/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 20/35
arithmetic operator we cannot jump from one segment to otherIf you will increment the far address beyond the maximum valoffset address instead of incrementing segment address it wiits offset address in cyclic order.
Example:
(q)What will be output of following c program?
int main(){inti;
charfar *ptr=(char*)0xB800FFFA;for(i=0;i
-
8/13/2019 C Interview Questions and Answers -TCS
21/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 21/35
2. Far pointerdoesnt normalize.
Hide
20
What is a cyclic property of data type in c? Explain with any
Explanation:
#include
intmain(){
signedcharc1=130;
signedcharc2=-130;
printf("%d %d",c1,c2);
return0;
}
Output: -126 126 (why?)
This situation is known as overflow of signed char.
Range of unsigned char is -128 to 127. If we will assig
greater than 127 then value of variable will be changed to
we will move clockwise direction as shown in the figure acc
number. If we will assign a number which is less than -12
have to move in anti-clockwise direction.
Hide
Pointers Interview questions
Data types Interview questions
Advance interview questions
String interview questions and answers
Commonly asked questions
TCS placement question +26 Recommend this on Google
104 comments:
blogsbyalo 10/29/10, 12:17 PM
great job!!Reply
vichy 11/9/10, 7:59 PM
Making a C program, to record the subjects taken by a student, the subjects removed, the approve
and calculate the GPA for that semester.
Ask C Questions
http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1289312977092#c764863779248069936http://www.facebook.com/vichy11http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1288334868883#c2876726827727701952http://blogsbyalo.wordpress.com/http://www.blogger.com/share-post.g?blogID=959939550345671470&postID=8888326969913641568&target=facebookhttp://www.blogger.com/share-post.g?blogID=959939550345671470&postID=8888326969913641568&target=twitterhttp://www.blogger.com/share-post.g?blogID=959939550345671470&postID=8888326969913641568&target=bloghttp://www.blogger.com/share-post.g?blogID=959939550345671470&postID=8888326969913641568&target=emailhttp://cquestions.com/2008/02/tcs-placement-question-with-solutions.http://cquestions.com/2009/09/interview-c-coding-question.htmlhttp://cquestions.com/2010/05/c-string-interview-questions-and.htmlhttp://cquestions.com/2011/12/advanced-c-interview-questions-and.htmlhttp://cquestions.com/2009/10/data-type-interview-questions.htmlhttp://cquestions.com/2009/10/pointer-interview-questions.htmlhttp://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink20http://3.bp.blogspot.com/-faEB4b6Fko8/Ttkc2GNOocI/AAAAAAAABkU/UdlsZu8_gD8/s1600/sc.jpeghttp://www.blogger.com/blogger.g?blogID=959939550345671470#Exlink19http://www.blogger.com/email-post.g?blogID=959939550345671470&postID=8888326969913641568 -
8/13/2019 C Interview Questions and Answers -TCS
22/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 22/35
Replies
The program should have the option of "going out"
Reply
Anonymous 12/8/10, 1:24 AM
Superb collection..thanks !!
just one bug to notify in Q.14..pr intf("Size of structure is: %d",*ptr); *ptr should be changed to ptr
Reply
Anonymous 12/8/10, 11:36 AM
Question 14 is correct one. No bug. It will work only Turbo c3.0
Reply
Anonymous 12/14/10, 9:50 AM
woov very good post.. thanks a lot to author...
Reply
Anonymous 1/9/11, 12:21 AM
superr collectionnnnnnn.............
Reply
Anonymous 1/29/11, 2:17 PM
great job what a super collectionnnnnnnnnnnn
Reply
Anonymous 2/9/11, 10:14 PM
i want a c program that will display this output:
A B C D E F G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B AA B B A
A A
Reply
Narottam Singh MCA 1/14/12, 4:36 PM
// This program is written in JAVA language .Which language u r using u can change
public class BB5
{
public static void main(String aa[])
{
int n=20;
int a=1;int b=n/2;
int c=65+b;
for(int k=1;k
-
8/13/2019 C Interview Questions and Answers -TCS
23/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 23/35
Reply
Anonymous 5/3/13, 9:18 AM
good site .create site gives information for c++,java,DBMS,unix
Anonymous 5/31/13, 9:48 AM
#include
int main (){
unsigned int j;
unsigned char i;
for(j=0;j
-
8/13/2019 C Interview Questions and Answers -TCS
24/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 24/35
Replies
Reply
Replies
else
{
printf(" %c",--alphabet);
}
}
}
}
}
SAMPLE OUTPUT:
enter the number of lines you want to print : 5
A B C D E D C B A
A B C D D C B A
A B C C B A
A B B A
A A
if u want dat particular format enter the number of lines as 7....
Reply
Anonymous 3/13/11, 3:09 AM
Great work ..Lots of hard work ...thanks a lot..becz it helps me a lot
Reply
Anil Kumar 3/17/11, 8:30 AM
main()
{
float a=0.7;
if(a
-
8/13/2019 C Interview Questions and Answers -TCS
25/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 25/35
Reply
Swarna Chandru 8/22/13, 1:34 AM
thanks a lot
Raghu 4/13/11, 5:32 PM
main()
{
float a=0.7;if(a
-
8/13/2019 C Interview Questions and Answers -TCS
26/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 26/35
ABCDDCBA
ABCCBA
ABBA
AAA
Reply
Garden sheds 6/2/11, 6:10 PM
C is a very interesting language and this is a basic of all language, if we have no knowledge
understand c++, this is a 1st stage of all programing language.
Reply
java tutoria l 6/2/11, 6:13 PM
Great! this post is very help for me.
Reply
Anonymous 6/22/11, 6:39 AM
Great work...really worthable one
Reply
Anonymous 7/21/11, 11:54 AM
awesum collection...
Reply
Anonymous 7/21/11, 8:29 PM
Awesome awesome awesome awesome awesome.......
Reply
Anonymous 7/27/11, 8:17 PM
really...helpful
Reply
Anonymous 7/28/11, 2:35 PM
awesome awesome awesome awesome awesome awesome awesome awesome awesome aweso
work..............:))))))
Reply
Anonymous 8/5/11, 2:34 PM
great post
Reply
Anonymous 8/8/11, 3:08 PM
good but need little more
Reply
Talib Hussain 8/17/11, 7:39 PM
all questions are very easy questions pls post difficult question and their answers
Reply
Anonymous 8/17/11, 7:50 PM
good
Reply
Gajanan 8/20/11, 2:38 PM
Thanks u vary much to create such super blog
Reply
http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1313831315013#c2194445380479867024http://www.blogger.com/profile/12684400577367832388http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1313590846656#c1622088689820574816http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1313590140978#c3596312331073728509http://www.blogger.com/profile/03185211861492099613http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1312796312283#c7952627809008585873http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1312535071603#c495193711160882032http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1311843959570#c1267841889621745656http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1311778027574#c8402197310796232506http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1311260365393#c4763506128221333792http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1311229492407#c5497331970822216514http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1308704950904#c8950407405675360885http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1307018607624#c6237771426224458782http://www.studiesinn.com/learn/Programming-Languages/Java-Language.htmlhttp://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1307018444557#c5145944154066986044http://www.simplyoutdoorsheds.co.uk/ -
8/13/2019 C Interview Questions and Answers -TCS
27/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 27/35
Anonymous 8/21/11, 3:56 PM
thank you sooooooooooooooooooooooo much...i find these questions so very useful...i could now
placement interviews..thanks once again..
Reply
Anonymous 8/24/11, 5:39 PM
I need answer for this question immediately before 3 hrs .. pls help me
1.write a c program to divide the no. 73897869by 256 without using +,-,/,* and loop statement??
Reply
Anonymous 8/24/11, 5:42 PM
and this too!
write 2 main () independent functions without using comments in a single program..pls help me friend
the answer immediately
Reply
Tanmay Chakrabarty 8/26/11, 12:52 PM
Wow....thats great. I have my Class Notes on C Programming. I shared them in my blog
Tanmay On Run
But your posts are much more helpful, My post will be helpful for class notes. But these posts are h
Nice to find your blog.
Reply
jigne sh 9/8/11, 2:27 AM
This is awesome post and good imformation
C interview questions
Reply
anurag_dake 9/8/11, 10:27 AM
1)void main()
{
float a=2.1;
if(a==2.1)
printf("TE");
else
printf("BE");
getch();
}
------------------------------------------------------
Whats the OUTPUT of Following Program
2)void main()
{
float a=2.0;
if(a==2.0)
printf("TE");else
printf("BE");
getch();
}
give Ans with reason....:)
Reply
Ritesh kumar 9/8/11, 11:00 AM
Hi Anurag,
Please check the question (1) of the following link: http://cquestionbank.blogspot.com/2009/09/c-ope
detial.html
I hope it will help you.
Reply
Anonymous 9/13/11, 8:38 PM
thanks a lot sir..........
Reply
http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1315926526288#c699629452602393998http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1315459811233#c1595303821681048917http://www.blogger.com/profile/08145649011863585828http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1315457868794#c3398979707041361601http://www.blogger.com/profile/15835604210378647727http://cinterviewquestions.org/http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1315429068055#c7257690646338860419http://jigneshbapna.com/http://tanmayonrun.blogspot.com/http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1314343329569#c9220956385871625261http://www.blogger.com/profile/08084800570982709032http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1314187936073#c8630769772003799601http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1314187766441#c143502569879892765http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1313922364730#c1679743908321169243 -
8/13/2019 C Interview Questions and Answers -TCS
28/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 28/35
RAJARAJAN 9/15/11, 2:46 AM
super..................site,&&&&&&&&&&&&&&&
super collection.
Reply
Anonymous 9/29/11, 8:32 PM
very very helpful, thank you!
Reply
sudhir10/4/11, 9:12 PM
excellent work
Reply
Anonymous 10/11/11, 10:02 PM
thanks............
supper.....D:)
Reply
Anonymous 10/12/11, 10:34 PM
i didnt even expect this much of material ..thanq : ) i think it definitly helps me alot..:)
Reply
ali.... 10/25/11, 12:30 AM
In the program for dangling pointer if ptr=call()
is written before clrscr() then it prints garbage value ...if written after it prints 26 correctly......Plz exp
turbo C
Reply
( ) 10/28/11, 8:40 AM
good very goodReply
Anonymous 11/5/11, 11:07 PM
Write a program for a GENERAL NUMBER CONVERTERS which include
binary, decimal, octa and hexadecimal. You need to write the program using C
language.
Reply
Ritesh kumar 11/6/11, 10:43 AM
Hi,
I hope this link will help you
http://cquestionbank.blogspot.com/2010/07/c-program-examples.html
Check Conversion ( Number System ) section
Reply
Unknown 11/8/11, 1:10 AM
well frnd i have a question---
why the constructor in c++ can't be virtual but destructor can be?
Reply
Anonymous 11/17/11, 3:33 PM
I really appreciate this. I shall donate some to this site.
Reply
Priyank Gupta 12/11/11, 7:15 AM
This is very use full for students....
http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1323567926465#c173479252149089619http://www.blogger.com/profile/12908707162730230249http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1321524222749#c8294127064521826840http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1320694858552#c4380970148340033308http://www.blogger.com/profile/00854225177908241305http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1320556427256#c703471507596409125http://www.blogger.com/profile/08145649011863585828http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1320514662919#c4077721920742632112http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1319771433255#c8032632508113490880http://www.blogger.com/profile/06123246062111427832http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1319482833491#c6444975014278195633http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1318439098755#c1628959529486638688http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1318350750444#c5150502493456759560http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1317742971817#c4844588327965568706http://www.blogger.com/profile/02440062680055439661http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1317308559270#c6894166526752695066http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1316034975305#c50122789664777569http://www.blogger.com/profile/16151271221934546624 -
8/13/2019 C Interview Questions and Answers -TCS
29/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 29/35
Replies
Reply
Reply
Anonymous 12/11/11, 11:11 PM
really good collection.....very useful
Reply
Anonymous 12/14/11, 7:56 PM
Anyone plz peast link to find turbo C for windows-7.
i have turboC.exe setup but not working properlly.
Reply
Zaad 12/14/11, 8:08 PM
Count the total words in a sentence,count once if word repeatting without using lib function.
eg- my name is jawed,my pet name is dog.
Answer-6
Reply
Anonymous 12/15/11, 4:26 PM
all genius....
great work...
Reply
raviteja 12/21/11, 1:33 PM
void main()
{
float a=2.1;
if(a==2.1)
printf("TE");
else
printf("BE");
getch();
}
In the above program a is float value but 2.1 value directly substituted in program taht value take dou
-- float takes after dot(.) 8 zero's.
-- Double takes after dot(.) 16 zero's.
so.....float is not equal to double.
ans is BE.
Reply
hitesh 6/9/13, 6:42 PM
above is right
Anonymous 12/21/11, 9:53 PM
write a program to find the rank of the number in the one dimensional array without using sorting and
Reply
Anonymous 1/3/12, 9:05 PM
c++ has any site like c
Reply
admin 1/5/12, 1:59 AM
nice job i didn't see this type of stuff .Why don't you make website, we will made website with l
Reply
http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1325708993143#c992802657744306487http://www.blogger.com/profile/17542614119026780394http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1325604927796#c2553598819558031198http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1324484631071#c8311234121072396775http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1370783544298#c4411902270113026895http://www.blogger.com/profile/00432375972592445320http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1324454586898#c4365178297836186600http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1323946585637#c6220383874219957233http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1323873486479#c2484738512258788715http://www.blogger.com/profile/07478324042226010391http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1323872802097#c6221846087873531462http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1323625285951#c5507798756397525447 -
8/13/2019 C Interview Questions and Answers -TCS
30/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 30/35
Anonymous 1/11/12, 2:12 PM
yes. good
Reply
Anonymous 1/12/12, 8:47 AM
thanks
Reply
sudhir rajput 1/14/12, 6:15 PM
#include
#include
void main()
{
int i,j;
clrscr();
for(i=9;i>=1;i++)
{
for(j=i-1;j
-
8/13/2019 C Interview Questions and Answers -TCS
31/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 31/35
Replies
Reply
Replies
Way to go!!!
Reply
Devendra Deshmukh 7/3/12, 11:36 AM
Awesome! Awesome ! Awesome!
Reply
Deals 2 Buy 11/26/12, 12:40 AM
Thanks a lot. this helps a lot for fast revision of C.
Reply
Shubhabrata Naha 1/24/13, 10:05 PM
*hi can u suggest me a good ebook for Recursion in C??
I cant understand recursion :(
plz help me out...
Reply
ritesh kumar 1/25/13, 8:47 AM
Shubharata, I hope this link will help you:
How to write function recursion program in easier way
Anonymous 2/20/13, 11:24 AM
it's is very useful..............
Reply
Anonymous 2/26/13, 8:43 AM
can u write a code of this output:
Enter a number:12345
:23451:34512
:45123
:51234
The highest number:51234
Reply
Anonymous 8/28/13, 2:54 PM
#include
#include
char *
rotate(char *str)
{
char *cp = str;
char ch = *cp++;
int i;
while (*cp) {
*(cp-1) = *cp++;
}
*(cp-1) = ch;
return str;
}
void
shuffle(char *str)
{
long bigval = 0;
int i;
long val = 0;
printf("Shuffling...\n");
for (i=0; i < strlen(str); i++) {
http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1377681893010#c6006512501648578774http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1361848401994#c1222330581516736210http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1361339691353#c344041737630026076http://www.cquestions.com/2009/06/function-recursion-in-c-programming.htmlhttp://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1359083873013#c4302225510464318736http://www.blogger.com/profile/08145649011863585828http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1359045325214#c7950267864633669667http://www.blogger.com/profile/06317273026396591890http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1353870658156#c2969752554677306266http://dealsindiadeals.com/http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html?showComment=1341295568545#c173480447802063335http://www.blogger.com/profile/11377816077807799319 -
8/13/2019 C Interview Questions and Answers -TCS
32/35
9/24/13 C interview questions and answers
www.cquestions.com/2010/10/c-interview-questions-and-answers.html 32/35
Reply
Replies
printf("%s\n", str = rotate(str));
val = atol(str);
if (!b igval || val > bigval ) {
bigval = val;
}
}
printf("Biggest shuffle is %d\n", bigval);
}
main()
{char buf[64];
printf("\nEnter +ve number : ");
scanf("%s",&buf);
shuffle(buf);
}
Anonymous 2/26/13, 8:46 AM
and this..
Enter a length of line:5
Enter P1:maria
Enter P1:gregEnter P1:juan
Enter P1:bitoy
Enter P1:melai
SAVE:4
I'LL wait ur reply.. i need it so badly
Reply
Anonymous 2/28/13, 7:19 PM
i need a program for this
1
2 3
4 5 67 8 9 10
Reply
hitesh 6/9/13, 10:59 PM
void main()
{
int j,i,k;
k=1;
for(i=1;i
-
8/13/2019 C Interview Questions and Answers -TCS
33/35
-
8/13/2019 C Interview Questions and Answers -TCS
34/35
-
8/13/2019 C Interview Questions and Answers -TCS
35/35
Interview Array C++ Examples C C++ PD
Grab this Headline Animator
MUST VISIT
Copyright@ritesh kumar. Powered by Blogger.
http://www.blogger.com/http://feedburner.google.com/fb/a/headlineanimator/install?id=322277lvil6oolcg8hbf545o58&w=1http://feeds.feedburner.com/~r/blogspot/mddYU/~6/1http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-0153514538688941&output=html&h=15&slotname=8451121234&adk=2174750934&w=728&lmt=1379965006&host=pub-1556223355139109&flash=11.8.800&url=http%3A%2F%2Fwww.cquestions.com%2F2010%2F10%2Fc-interview-questions-and-answers.html&dt=1379986201751&bpp=31&bdt=4951&shv=r20130917&cbv=r20130906&saldr=sa&prev_slotnames=6465271747%2C9780378087%2C7530551827&correlator=1379986200946&frm=20&ga_vid=1576325231.1379986201&ga_sid=1379986201&ga_hid=1510954612&ga_fc=1&u_tz=330&u_his=1&u_java=1&u_h=768&u_w=1366&u_ah=728&u_aw=1366&u_cd=32&u_nplug=7&u_nmime=16&dff=arial&dfs=14&adx=425&ady=25759&biw=1349&bih=667&oid=3&ref=https%3A%2F%2Fwww.google.co.in%2F&vis=2&fu=0&ifi=4&dtd=44&xpc=ovxjajCVck&p=http%3A//www.cquestions.com&rl_rc=true&adsense_enabled=true&ad_type=text&ui=rc:0&oe=UTF8&height=15&width=728&format=fpkc_al_lp&kw_type=radlink&prev_fmts=728x15_0ads_al&rt=ChBSQOsZAAmsKgrioQKLADo-EglDIEMrKyBQREYaCKzlz-qnAH88KAFSEwiP8daa8eK5AhUhBeIKHQEeAPo&hl=en&kw0=Interview&kw1=Array&kw2=C%2B%2B+Examples&kw3=C+C%2B%2B+PDF&okw=C+C%2B%2B+PDFhttp://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-0153514538688941&output=html&h=15&slotname=8451121234&adk=2174750934&w=728&lmt=1379965006&host=pub-1556223355139109&flash=11.8.800&url=http%3A%2F%2Fwww.cquestions.com%2F2010%2F10%2Fc-interview-questions-and-answers.html&dt=1379986201751&bpp=31&bdt=4951&shv=r20130917&cbv=r20130906&saldr=sa&prev_slotnames=6465271747%2C9780378087%2C7530551827&correlator=1379986200946&frm=20&ga_vid=1576325231.1379986201&ga_sid=1379986201&ga_hid=1510954612&ga_fc=1&u_tz=330&u_his=1&u_java=1&u_h=768&u_w=1366&u_ah=728&u_aw=1366&u_cd=32&u_nplug=7&u_nmime=16&dff=arial&dfs=14&adx=425&ady=25759&biw=1349&bih=667&oid=3&ref=https%3A%2F%2Fwww.google.co.in%2F&vis=2&fu=0&ifi=4&dtd=44&xpc=ovxjajCVck&p=http%3A//www.cquestions.com&rl_rc=true&adsense_enabled=true&ad_type=text&ui=rc:0&oe=UTF8&height=15&width=728&format=fpkc_al_lp&kw_type=radlink&prev_fmts=728x15_0ads_al&rt=ChBSQOsZAAmsJwrioQKLADo-EgxDKysgRXhhbXBsZXMaCKEyDpjZgmraKAFSEwiP8daa8eK5AhUhBeIKHQEeAPo&hl=en&kw0=Interview&kw1=Array&kw2=C%2B%2B+Examples&kw3=C+C%2B%2B+PDF&okw=C%2B%2B+Exampleshttp://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-0153514538688941&output=html&h=15&slotname=8451121234&adk=2174750934&w=728&lmt=1379965006&host=pub-1556223355139109&flash=11.8.800&url=http%3A%2F%2Fwww.cquestions.com%2F2010%2F10%2Fc-interview-questions-and-answers.html&dt=1379986201751&bpp=31&bdt=4951&shv=r20130917&cbv=r20130906&saldr=sa&prev_slotnames=6465271747%2C9780378087%2C7530551827&correlator=1379986200946&frm=20&ga_vid=1576325231.1379986201&ga_sid=1379986201&ga_hid=1510954612&ga_fc=1&u_tz=330&u_his=1&u_java=1&u_h=768&u_w=1366&u_ah=728&u_aw=1366&u_cd=32&u_nplug=7&u_nmime=16&dff=arial&dfs=14&adx=425&ady=25759&biw=1349&bih=667&oid=3&ref=https%3A%2F%2Fwww.google.co.in%2F&vis=2&fu=0&ifi=4&dtd=44&xpc=ovxjajCVck&p=http%3A//www.cquestions.com&rl_rc=true&adsense_enabled=true&ad_type=text&ui=rc:0&oe=UTF8&height=15&width=728&format=fpkc_al_lp&kw_type=radlink&prev_fmts=728x15_0ads_al&rt=ChBSQOsZAAmsIwrioQKLADo-EgVBcnJheRoIDi7nz0WvEjQoAVITCI_x1prx4rkCFSEF4godAR4A-g&hl=en&kw0=Interview&kw1=Array&kw2=C%2B%2B+Examples&kw3=C+C%2B%2B+PDF&okw=Arrayhttp://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-0153514538688941&output=html&h=15&slotname=8451121234&adk=2174750934&w=728&lmt=1379965006&host=pub-1556223355139109&flash=11.8.800&url=http%3A%2F%2Fwww.cquestions.com%2F2010%2F10%2Fc-interview-questions-and-answers.html&dt=1379986201751&bpp=31&bdt=4951&shv=r20130917&cbv=r20130906&saldr=sa&prev_slotnames=6465271747%2C9780378087%2C7530551827&correlator=1379986200946&frm=20&ga_vid=1576325231.1379986201&ga_sid=1379986201&ga_hid=1510954612&ga_fc=1&u_tz=330&u_his=1&u_java=1&u_h=768&u_w=1366&u_ah=728&u_aw=1366&u_cd=32&u_nplug=7&u_nmime=16&dff=arial&dfs=14&adx=425&ady=25759&biw=1349&bih=667&oid=3&ref=https%3A%2F%2Fwww.google.co.in%2F&vis=2&fu=0&ifi=4&dtd=44&xpc=ovxjajCVck&p=http%3A//www.cquestions.com&rl_rc=true&adsense_enabled=true&ad_type=text&ui=rc:0&oe=UTF8&height=15&width=728&format=fpkc_al_lp&kw_type=radlink&prev_fmts=728x15_0ads_al&rt=ChBSQOsZAAmsFQrioQKLADo-EglJbnRlcnZpZXcaCMyRnGLXppEAKAFSEwiP8daa8eK5AhUhBeIKHQEeAPo&hl=en&kw0=Interview&kw1=Array&kw2=C%2B%2B+Examples&kw3=C+C%2B%2B+PDF&okw=Interviewhttp://www.google.com/url?ct=abg&q=https://www.google.com/adsense/support/bin/request.py%3Fcontact%3Dabg_afc%26url%3Dhttp://www.cquestions.com/2010/10/c-interview-questions-and-answers.html%26gl%3DIN%26hl%3Den%26client%3Dca-pub-0153514538688941&usg=AFQjCNF15w6Khm823T9VeJG6GcU43TR8oA