Top

C Programming

31.

What is a command-line argument?

Ans:

The argument passed to the main() function while executing the program is known as the command-line argument. For example:

main(int count, char *args[]){  
//code to  be executed  
}

 

32.

What is Preprocessor?

Ans:

A Preprocessor Directive is considered as a built-in predefined function or macro that acts as a directive to the compiler and it gets executed before the actual C Program is executed.

33.

What is the main difference between the Compiler and the Interpreter?

Ans:

The compiler is used in C Language and it translates the complete code into the Machine Code in one shot. On the other hand, Interpreter is used in Java Programming Langauge and other high-end programming languages. It is designed to compile code in a line-by-line fashion.

34.

What are the valid places for the keyword break to appear?

Ans:

A break can appear only within the looping control and switch statement. The purpose of the break is to bring the control out from the said blocks.

 

35.

Mention the features of C Programming Language.

Ans:

Following are the features of C Programming Language:

  • Memory Management
  • High-Level Language
  • Faster
  • Structured Language
  • Pointers
  • Rich Library
  • Recursion
  • Extensible

36.

Explain the syntax for for loop.

Ans:

for(expression-1;expression-2;expression-3) {
   //set of statements
}

When control reaches for expression-1 is executed first. Then following expression-2, and if expression-2 evaluates to non-zero ‘set of statements’ and expression-3 is executed, follows expression-2.

37.

What is an infinite loop?

Ans:

A loop executing repeatedly as the loop-expression always evaluates to true such as

while(0 == 0) {
}

 

38.

How can we store a negative integer?

Ans:

To store a negative integer, we need to follow the following steps. Calculate the two’s complement of the same positive integer.

Eg: 1011 (-5)

Step-1: One’s complement of 5: 1010

Step-2: Add 1 to above, giving 1011, which is -5

39.

What is the difference between including the header file with-in angular braces < > and double quotes " "

Ans:

If a header file is included within < > then the compiler searches for the particular header file only within the built-in include path. If a header file is included within " ", then the compiler searches for the particular header file first in the current working directory, if not found then in the built-in include path.

40.

What is an array in C?

Ans:

An Array is a group of similar types of elements. It has a contiguous memory location. It makes the code optimized, easy to traverse and easy to sort. The size and type of arrays cannot be changed after their declaration.

Arrays are of two types:

  • One-dimensional array: One-dimensional array is an array that stores the elements one after the another.
data_type array_name[size];
  • Multidimensional array: Multidimensional array is an array that contains more than one array.
data_type array_name[size];

 

 

Loading…
Tags: C Programming Interview Questions and Answers || C Programming Sort Questions and Answers || C Programming Detailed Questions and Answers || C Programming Tutorial