Variable in C Language - General Knowledge Question and Answer

Variable in C Language - Question and Answer

Which of the following is a valid variable name declaration?  


int ;a5;
int _a4;
int #a6;
int @a2;

Answer:

Variable name can start with only two special characters, which are _(underscore) and $(doller).


Share Me:

Which of the following is not a valid variable name declaration?  


int a;
int a_5;
int _g;
int 6_d;

Answer:

Variable name cannot start with a digit.


Share Me:

All keywords in C are in  


UpperCase letters
LowerCase letters
CamelCase letters
None

Answer:

As C is a case-sensitive language, all keywords must be written in lowercase.


Share Me:

In case of ordinary int variables  


no bit is reserved for sign
rightmost bit is reserved for sign
leftmost bit is reserved for sign
None

Answer:

In case of ordinary int variables leftmost bit is reserved for sign.


Share Me:

Which of the following below is valid C keywords?  


null
integer
int
None

Answer:

int is valid keyword in C.


Share Me:

C programs are converted from high level to machine level language with the help of  


OS
Editor
Compiler
None

Answer:

C programs are converted from high level to machine level language with the help of Compiler.

Compiler: A compiler is a software program that transforms high-level source code that is written by a developer in a high-level programming language into a low-level object code (binary code) in machine language, which can be understood by the processor. The process of converting high-level programming into machine language is known as compilation.


Share Me:

Which of the following is not a variable type?  


int
float
char
real

Answer:

real is not a variable type.


Share Me:

Which of the following is correct for variable names in C?  


Variable names cannot start with a digit
They can contain alphanumeric characters as well as special characters
Variable can be of any length
It is not an error to declare a variable to be one of the keywords(like goto, static)

Answer:

Variable names cannot start with a digit.


Share Me:

Which of the following is not a valid variable name declaration?  


#define PI 3.14
float PI = 3.14;
double PI = 3.14;
int PI = 3.14;

Answer:

#define PI 3.14 is a macro preprocessor, it is a textual substitution.


Share Me:

Which of following is not a valid name for a C variable?  


newdelhi
new_delhi
new delhi
none

Answer:

new delhi is not a valid name for a C variable, because of space.


Share Me:

Which one is not a c keyword  


auto
extern
register
main

Answer:

main

Share Me:

What will be the output of the following program?
 #include"stdio.h"
main()
{
/* assuming that the i is not defined in in any other file */	
 extern int i;
 i = 10 ;
 printf("%d", i) ;
}
 
 


10
0
Compile time error
Linker Error

Answer:

Linker Error
Undefined symbol 'i'

Share Me:

What would be the output of the following program?
#include  
void main()
{
   extern int i;
   i =20;
   printf("sizeof(i)");
}

 


2
4
would vary from compiler to coompiler
undefined reference to `i'

Answer:

Error: undefined reference to `i'

Share Me: