Getting a first job is a dream for everyone in this world. A typical job seeker refers hundreds of books, sample questions papers and get himself geared for the big day. A neatly worn dress, with all the certificates on hand, the testing starts the moment the interview panel starts questioning his expert areas.
Most of the questions are asked from a single basic language - C. If you have quoted your skills in C as your strength, then you are sure to be asked questions starting from the basics. It is wise that you have a good brush up of the language before even you write about it in your CV. Never underestimate the interview panel. The panel is always talented enough to estimate you with a few questions.
I'm listing down some of the questions in C which is really elementary and you ought to have a good grasp on them. So, before even you write C as your primary skill, make sure that you know something on the questions listed below. A very simplified way of explaining the answers to these questions will also be an added advantage. So, here we go
1) What is the difference between malloc() and calloc() ?
2) Give an example for passing by value and passing be reference. When should you use them and why? (believe me! Most of the candidates get wrong here)
3) What is a register variable?
4) What do we use typedef for?
5) What is the difference between Structure and Union?
6) What is a far pointer? When do we use it?
7) What is a NULL macro? What is the difference between NULL macro and NULL pointer?
8) Write a simple file handling program in C, opening a file, write to the file and close it.
9) Which bit wise operator is suitable for checking whether a particular bit is on or off?
10) How will you compare two strings, without using strcmp?
11) What do the functions atoi(), itoa() do?
12) What are the advantages of using pointers in a program?
13) Explain different storages classes in C.
14) What do 'c' and 'v' stand for in argc and argv?
15) What is the difference between rand() and random() ?
Most of the questions are asked from a single basic language - C. If you have quoted your skills in C as your strength, then you are sure to be asked questions starting from the basics. It is wise that you have a good brush up of the language before even you write about it in your CV. Never underestimate the interview panel. The panel is always talented enough to estimate you with a few questions.
I'm listing down some of the questions in C which is really elementary and you ought to have a good grasp on them. So, before even you write C as your primary skill, make sure that you know something on the questions listed below. A very simplified way of explaining the answers to these questions will also be an added advantage. So, here we go
1) What is the difference between malloc() and calloc() ?
2) Give an example for passing by value and passing be reference. When should you use them and why? (believe me! Most of the candidates get wrong here)
3) What is a register variable?
4) What do we use typedef for?
5) What is the difference between Structure and Union?
6) What is a far pointer? When do we use it?
7) What is a NULL macro? What is the difference between NULL macro and NULL pointer?
8) Write a simple file handling program in C, opening a file, write to the file and close it.
9) Which bit wise operator is suitable for checking whether a particular bit is on or off?
10) How will you compare two strings, without using strcmp?
11) What do the functions atoi(), itoa() do?
12) What are the advantages of using pointers in a program?
13) Explain different storages classes in C.
14) What do 'c' and 'v' stand for in argc and argv?
15) What is the difference between rand() and random() ?
I had earlier given some basic questions for which every candidate must know the answer before appearing for an interview, projecting C language as one of the skills. Here we go a little wider into the language and see some more interview questions. If you want to have a look at the older post, click here.
These questions are highly probably to be asked in C based interviews. If you can explain the answers to these questions in a very elementary way rather than in a bookish way, then it will be a additional bonus for you. Prepare the answers to the questions listed below before you appear for an interview. It will be really helpful to you.
1) What is the basic difference between an array and a pointer?
2) What is the purpose of realloc();?
3) How are pointer variables initialized?
4) Write a simple program in C to print "Hello World" using pointers.
5) What is the difference between main() and void main() ?
6) What is modular programming? Why should a program be modular in first place? How to achieve modular programming in C?
7) What are the advantages of 'auto' variables?
8) Why n++ executes faster than n+1 ?
9) Write a program in C to print the address of a variable?
10) How can you make a PC to burn using a C program? (Interesting one! Try your hand)
11) What is the difference between stack and queue?
12) List some queue algorithms.
13) When would you use a pointer to a function?
14) How do you convert a string to a long integer? Where can you use this in real time?
15) What is the difference between strcpy and memcpy?
16) What is a pragma?
17) What is the difference between #include
In this sample Interview Question series, let us focus on program - output type of questions that can be asked in C.
Part I, II and III were focusing on understanding the basics of the language. This part will help you in tackling questions during interview. You may get questions of similar kind during any IT interview. Such questions are likely to be asked either during the initial screening test or during a face to face interview. For the code snippets provided below, predict the output of the program. I strongly advise you to execute the code snippets and understand them completely. This will help you to answer the questions asked on similar lines during a real interview.
1)
void main()
{
int const * a=25;
printf("%d",++(*a));
}
2)
main()
{
char s2[ ]="man";
int i;
for(i=0;s2[ i ];i++)
printf("\n%c%c%c%c",s2[ i ],*(s2+i),*(i+s2),i[s2]);
}
3)
main()
{
float str1 = 1.1;
double str2 = 1.1;
if(str1==str2)
printf("C is a good language");
else
printf("C is a very good language");
}
4)
main()
{
static int var2 = 5;
printf("%d ",var2--);
if(var2)
main();
}
5)
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; }
}
6)
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);
}
7)
main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}
8)
main()
{
int i=3;
switch(i)
{
default:printf("zero");
case 1: printf("one");
break;
case 2:printf("two");
break;
case 3: printf("three");
break;
}
}
9)
main()
{
int i=50;
i=!i>14;
Printf ("i=%d",i);
}
These questions are highly probably to be asked in C based interviews. If you can explain the answers to these questions in a very elementary way rather than in a bookish way, then it will be a additional bonus for you. Prepare the answers to the questions listed below before you appear for an interview. It will be really helpful to you.
1) What is the basic difference between an array and a pointer?
2) What is the purpose of realloc();?
3) How are pointer variables initialized?
4) Write a simple program in C to print "Hello World" using pointers.
5) What is the difference between main() and void main() ?
6) What is modular programming? Why should a program be modular in first place? How to achieve modular programming in C?
7) What are the advantages of 'auto' variables?
8) Why n++ executes faster than n+1 ?
9) Write a program in C to print the address of a variable?
10) How can you make a PC to burn using a C program? (Interesting one! Try your hand)
11) What is the difference between stack and queue?
12) List some queue algorithms.
13) When would you use a pointer to a function?
14) How do you convert a string to a long integer? Where can you use this in real time?
15) What is the difference between strcpy and memcpy?
16) What is a pragma?
17) What is the difference between #include
In this sample Interview Question series, let us focus on program - output type of questions that can be asked in C.
Part I, II and III were focusing on understanding the basics of the language. This part will help you in tackling questions during interview. You may get questions of similar kind during any IT interview. Such questions are likely to be asked either during the initial screening test or during a face to face interview. For the code snippets provided below, predict the output of the program. I strongly advise you to execute the code snippets and understand them completely. This will help you to answer the questions asked on similar lines during a real interview.
1)
void main()
{
int const * a=25;
printf("%d",++(*a));
}
2)
main()
{
char s2[ ]="man";
int i;
for(i=0;s2[ i ];i++)
printf("\n%c%c%c%c",s2[ i ],*(s2+i),*(i+s2),i[s2]);
}
3)
main()
{
float str1 = 1.1;
double str2 = 1.1;
if(str1==str2)
printf("C is a good language");
else
printf("C is a very good language");
}
4)
main()
{
static int var2 = 5;
printf("%d ",var2--);
if(var2)
main();
}
5)
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; }
}
6)
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);
}
7)
main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}
8)
main()
{
int i=3;
switch(i)
{
default:printf("zero");
case 1: printf("one");
break;
case 2:printf("two");
break;
case 3: printf("three");
break;
}
}
9)
main()
{
int i=50;
i=!i>14;
Printf ("i=%d",i);
}
You are currently in the Part III set for Interview Questions in C Programming language. If you want to check Part I click here and for Part II, click here.
These questions will really help in preparing for your interview and you can excel if you have a good knowledge on these ones.
1) How will you print the character % using C?
2) Write a program in C to print the first five numbers of a Fibonacci series.
3) How will you convert an unsigned long integer value to a string using C?
4) A header file in C should always have an extension '.h'. True or False? Justify.
5) List some sorting algorithms in C. Which is the quickest approach and why?
6) What is the benefit of using const to declare constants in C?
7) Who is the founder of C language..(this was asked to one of my friends)
8) How can you print a string in C without using printf?
9) Which library in C is used for drawing menus?
10) How can you open a PDF file using C?
11) Write a program in C to swap two numbers without using a temporary variable.
12) How testing of a C program becomes easier using functions?
13) What is the difference between exit() and return?
14) How can you make a function to return more than one value in C?
15) Which is better to use malloc() or calloc() ?
16) Write the best algorithm to check if a number is prime or not.
17) How can you override a defined macro?
18) For what purpose, would you use #line in C?
19) What is the difference between text mode and binary mode?
20) Write a C program to swap two numbers using pointers.
In the next part of this series, let us discuss on program -> output model questions. Such questions will be asked mostly during aptitude test and is unlikely to be asked during interviews.
These questions will really help in preparing for your interview and you can excel if you have a good knowledge on these ones.
1) How will you print the character % using C?
2) Write a program in C to print the first five numbers of a Fibonacci series.
3) How will you convert an unsigned long integer value to a string using C?
4) A header file in C should always have an extension '.h'. True or False? Justify.
5) List some sorting algorithms in C. Which is the quickest approach and why?
6) What is the benefit of using const to declare constants in C?
7) Who is the founder of C language..(this was asked to one of my friends)
8) How can you print a string in C without using printf?
9) Which library in C is used for drawing menus?
10) How can you open a PDF file using C?
11) Write a program in C to swap two numbers without using a temporary variable.
12) How testing of a C program becomes easier using functions?
13) What is the difference between exit() and return?
14) How can you make a function to return more than one value in C?
15) Which is better to use malloc() or calloc() ?
16) Write the best algorithm to check if a number is prime or not.
17) How can you override a defined macro?
18) For what purpose, would you use #line in C?
19) What is the difference between text mode and binary mode?
20) Write a C program to swap two numbers using pointers.
In the next part of this series, let us discuss on program -> output model questions. Such questions will be asked mostly during aptitude test and is unlikely to be asked during interviews.
No comments:
Post a Comment