Top

C Programming

21.

Can we assign a float variable to a long integer variable?

Ans:

Yes, with loss of fractional part.

22.

Explain Local Static Variables and what is their use?

Ans:

A local static variable is a variable whose life doesn’t end with a function call where it is declared. It extends for the lifetime of the complete program. All calls to the function share the same copy of local static variables.

#include
void fun() 
{ 
    static int x; 
    printf("%d ", x); 
    x = x + 1; 
} 
int main() 
{ 
    fun(); 
    fun(); 
    return 0; 
}

Output: 0 1

23.

Where an automatic variable is stored?

Ans:

Every local variable by default being an auto variable is stored in stack memory.

24.

What is the difference between variable declaration and variable definition?

Ans:

Declaration associates type to the variable whereas definition gives the value to the variable.

25.

What is the acronym for ANSI?

Ans:

The ANSI stands for " American National Standard Institute." It is an organization that maintains a broad range of disciplines including photographic film, computer languages, data encoding, mechanical parts, safety, and more.

26.

What is the newline escape sequence?

Ans:

The new line escape sequence is represented by "\n". It inserts a new line on the output screen.

27.

Can I use int datatype to store 32768 value?

Ans:

No, the Integer datatype will support the range between -32768 and 32767. Any value exceeding that will not be stored. We can either use float or long int.

28.

Explain the purpose of the function sprintf().

Ans:

Prints the formatted output onto the character array.

29.

What is typecasting?

Ans:

Typecasting is a way to convert a variable/constant from one type to another type.

30.

What is a C Token?

Ans:

Keywords, Constants, Special Symbols, Strings, Operators, Identifiers used in the C program are referred to as C Tokens.

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