FreeJobAlert.Com

Government Jobs | Results | Admit Cards

c language interview questions | Part 6

If you would like to view All C language interview questions only at one place visit below link
All C Language Interview Questions

51. Difference between formal argument and actual argument?
Ans: Formal arguments are the arguments available in the function definition. They are preceded by
their own data type. Actual arguments are available in the function call. These arguments are given
as constants or variables or expressions to pass the values to the function.

52. Is it possible to have more than one main() function in a C program ?
Ans: The function main() can appear only once. The program execution starts from main.

53. What is the difference between an enumeration and a set of pre-processor # defines?
Ans: There is hardly any difference between the two, except that #defines has a global effect (throughout the file) whereas an enumeration can have an effect local to the block if desired. Some advantages of enumeration are that the numeric values are automatically assigned whereas in #define we have to explicitly define them. A disadvantage is that we have no control over the size of enumeration variables.

54. How are Structure passing and returning implemented by the complier?
Ans: When structures are passed as argument to functions, the entire structure is typically pushed on
the stack. To avoid this overhead many programmer often prefer to pass pointers to structure instead of actual structures. Structures are often returned from functions in a location pointed to by an extra, compiler-supported ‘hidden’ argument to the function.

55. IMP>what is the similarity between a Structure, Union and enumeration?
Ans: All of them let the programmer to define new data type.

56. Can a Structure contain a Pointer to itself?
Ans: Yes such structures are called self-referential structures.

57. How can we read/write Structures from/to data files?
Ans: To write out a structure we can use fwrite() as Fwrite( &e, sizeof(e),1,fp);Where e is a structure
variable. A corresponding fread() invocation can read the structure back from file. calling fwrite() it writes out sizeof(e) bytes from the address &e. Data files written as memory images with fwrite(),however ,will not be portable, particularly if they contain floating point fields or Pointers. This is because memory layout of structures is machine and compiler
dependent. Therefore, structures written as memory images cannot necessarily be read back by programs running on other machine, and this is the important concern if the data files you’re writing will ever be interchanged between machines.

58. Write a program which employs Recursion?
Ans: int fact(int n) { return n > 1 ? n * fact(n – 1) : 1; }

59.Write a program which uses Command Line Arguments?
Ans:

#include
void main(int argc,char *argv[])
{
int i;
clrscr();
for(i=0;i
printf(“\n%d”,argv[i]);
}

60. Difference between array and pointer?
Ans:
Array
1- Array allocates space automatically
2- It cannot be resized
3- It cannot be reassigned
4- sizeof (arrayname) gives the number of bytes occupied by the array.
Pointer
1-Explicitly assigned to point to an allocated space.
2-It can be sized using realloc()
3-pointer can be reassigned.
4-sizeof (p) returns the number of bytes used to store the pointer variable p.

Related Fresher Interview Questions

1. C Language Interview Questions
2. C++ Language Interview Questions
3. Data Structures Interview Questions
4. DBMS Interview Questions
5. Operating System Interview Questions
6. UNIX Interview Questions

Tags: c fresher interview questions, c interview, c interview questions, c interview questions and answers, c interview questions and answers for freshers, c interview questions for freshers, c interview questions with answers, c language interview questions, c language interview questions and answers, fresher interview questions, fresher interview questions and answers, fresher interview questions and answers on c, fresher interview questions on c, fresher interview questions with answers, interview questions on c, it fresher interview questions, it fresher interview questions and answers, questions for interview, questions on c

Leave a Comment