Interview Questions on C - Data types

1. What is Datatype and what are all the Data type exist in C language?

Definition :- Datatype refers that particular variable or function belongs to particular type.
Mainly  There are two data types exist in C language 
1. Basic datatypes

Type Storage size Value range
Char 1 byte -128 to 127 or 0 to 255
Int 2 bytes -32,768 to 32,767 or -
Long 4 bytes -2,147,483,648 to 2,147,483,647
Float 4 byte 
Double 8 bytes 

2. How to initialize char value?

Cahr ch= ‘f’; (value enclosed with sigle quotes)

3. When we use void type?

Basically void type specifies no value is available.
It is used in 3 kinds of situations
1. Use return type as void  :- if fumction does not return any value. Then we can return void.
2. Pass void as argument :- if function does not accept any arguments. Then we can pass void as argument.
3. Pointers to viod :- A pointer of type void * represents the address of an object,

4. What is the size of void pointer?

2 bytes(any data type has size of 2 bytes).

5. What is variable and how to declare a Variable in C?

Def :- Variable is name of memory location
Syntax :-
type variable_name = value;
int d = 3, f = 5; 

6. What is lvalue and rvalue?

Expressions that refer to a memory location is called "lvalue" 
Most likely Lvalue exist left hand side express ion of ‘=’ operator
The term rvalue refers to a data value that is stored at some address in memory. 
Mostly Rvalue is at  right hand side operator of ‘=’ operator
Ex :–  a=5; 
Here a is lvalue
5 is r value. 

7. What is Constant Variable?

Def:-  The Variable Which cannot be changed the value during  program execution.

8. How to define Constant Values?

There are two simple ways in C to define constants:
1. Using #define preprocessor. 
#define identifier value
2. Using const keyword.
const type variable = value;

9. How to print new line in C?

By using ‘\n’ in printf statement

10. What is String?

String is colection of characters enclosed with in double quotes.
Ex :-  “asdfg”, “apple”

11. How to write one string in two lines?

By using \

Ex :- “good mo\