October 12, 2018

Sreekanth B

eClerx Most Frequently Asked C Language Interview Questions Answers

What is the equivalent code of the following statement in WHILE LOOP format?

for (a=1; a<=100; a++)

printf ("%d\n", a * a);



while (a<=100) {

printf ("%d\n", a * a);


How do you access the values within an array?

Arrays contain a number of elements, depending on the size you gave it during variable declaration. Each element is assigned a number from 0 to number of elements-1. To assign or retrieve the value of a particular element, refer to the element number. For example: if you have a declaration that says “intscores[5];”, then you have 5 accessible elements, namely: scores[0], scores[1], scores[2], scores[3] and scores[4].

Can I use  “int” data type to store the value 32768? Why?

No. “int” data type is capable of storing values from -32768 to 32767. To store 32768, you can use “long int” instead. You can also use “unsigned int”, assuming you don’t intend to store negative values.

Can two or more operators such as \n and \t be combined in a single line of program code?

Yes, it’s perfectly valid to combine operators, especially if the need arises. For example: you can have a code like ” printf (“Hello\n\n\’World\'”) ” to output the text “Hello” on the first line and “World” enclosed in single quotes to appear on the next two lines.
eClerx Most Frequently Asked C Language Interview Questions Answers
eClerx Most Frequently Asked C Language Interview Questions Answers

Why is it that not all header files are declared in every C program?

The choice of declaring a header file at the top of each C program would depend on what commands/functions you will be using in that program. Since each header file contains different function definitions and prototype, you would be using only those header files that would contain the functions you will need. Declaring all header files in every program would only increase the overall file size and load of the program, and is not considered a good programming style.

When is the “void” keyword used in a function?

When declaring functions, you will decide whether that function would be returning a value or not. If that function will not return a value, such as when the purpose of a function is to display some outputs on the screen, then “void” is to be placed at the leftmost part of the function header. When a return value is expected after the function execution, the data type of the return value is placed instead of “void”.

What are compound statements?

Compound statements are made up of two or more program statements that are executed together. This usually occurs while handling conditions wherein a series of statements are executed when a TRUE or FALSE is evaluated. Compound statements can also be executed within a loop. Curly brackets { } are placed before and after compound statements.

Write a program to check Armstrong number in C?

int n,r,sum=0,temp;    //declaration of variables.
clrscr(); //It clears the screen.
printf("enter the number=");
printf("armstrong  number ");
printf("not armstrong number");
getch();  //It reads a character from the keyword.

Write a program to reverse a given number in C?

int n, reverse=0, rem;    //declaration of variables.
clrscr(); // It clears the screen.
printf("Enter a number: ");
scanf("%d", &n);
printf("Reversed Number: %d",reverse);
getch();  // It reads a character from the keyword.

What does the && operator do in a program code?

The && is also referred to as AND operator. When using this operator, all conditions specified must be TRUE before the next action can be performed. If you have 10 conditions and all but 1 fails to evaluate as TRUE, the entire condition statement is already evaluated as FALSE.

In C programming, what command or code can be used to determine if a number of odd or even?

There is no single command or function in C that can check if a number is odd or even. However, this can be accomplished by dividing that number by 2, then checking the remainder. If the remainder is 0, then that number is even, otherwise, it is odd. You can write it in code as:

if (num % 2 == 0)


Subscribe to get more Posts :