C-Language Interview Questions
1 .
What is command line argument?
The argument passed to the `main()` function while executing the program is known as command line argument.

For example :

``````main(int count, char *args[]){
//code to  be executed
} ``````
2 .
What is the difference between near, far and huge pointers?
A virtual address is composed of the selector and offset.

A near pointer doesn't have explicit selector whereas far, and huge pointers have explicit selector. When you perform pointer arithmetic on the far pointer, the selector is not modified, but in case of a huge pointer, it can be modified.

These are the non-standard keywords and implementation specific. These are irrelevant in a modern platform.
3 .
Write a program to check Armstrong number in C?
Before going to write the c program to check whether the number is Armstrong or not, let's understand what is Armstrong number.

Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.

Let's try to understand why 153 is an Armstrong number.

``````153 = (1*1*1)+(5*5*5)+(3*3*3)
where:
(1*1*1)=1
(5*5*5)=125
(3*3*3)=27
So:
1+125+27=153  ​``````

Let's see the c program to check Armstrong Number in C.

``````#include<stdio.h>
int main()
{
int n,r,sum=0,temp;
printf("enter the number=");
scanf("%d",&n);
temp=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(temp==sum)
printf("armstrong  number ");
else
printf("not armstrong number");
return 0;
} ``````

Output :
``````enter the number=153
armstrong number

enter the number=5
not armstrong number``````
4 .
What is the process to create increment and decrement statement in C?
There are two possible methods to perform this task.

Use increment (++) and decrement (-) operator.
Example :
``When x=4, x++ returns 5 and x- returns 3.​``
Use conventional + or – sign.
Example :
``When x=4, use x+1 to get 5 and x-1 to get 3.​``
5 .
What is the difference between abs() and fabs() functions?
Both functions are to retrieve absolute value. `abs()` is for integer values and `fabs()` is for floating type numbers. Prototype for `abs()` is under the library file `< stdlib.h >` and `fabs()` is under `< math.h >`.
6 .
What is the difference between ++a and a++?
"`++a`"  is called prefixed increment and the increment will happen first on a variable. "`a++`"is called postfix increment and the increment happens after the value of a variable used for the operations.
7 .
What is a nested loop?
A loop that runs within another loop is referred to as a nested loop. The first loop is called the Outer Loop and the inside loop is called the Inner Loop. The inner loop executes the number of times defined in an outer loop.
8 .
What is the significance of C program algorithms?
The algorithm is created first and it contains step by step guidelines on how the solution should be. Also, it contains the steps to consider and the required calculations/operations within the program.
9 .
Is it possible to use curly brackets ({}) to enclose a single line code in C program?
Yes, it works without any error. Some programmers like to use this to organize the code. But the main purpose of curly brackets is to group several lines of codes.
10 .
Is it possible to store 32768 in an int data type variable?
Int data type is capable of storing values between 32768 to 32767. To store 32768 a modifier has to be used with int data type and hence Long Int can be used. If there are no negative values, unsigned int can also be used.