Topic C Programming MCQ : Variable Naming Rules
Related Study Material Rules for Declaring Variable Name
Question 1
Following program will be compile successfully -
#include<stdio.h>
int main(){
    long int _AH = 15;
    printf("%ld",_AH);
    return 0;
}
A
No
B
Yes
Question 1 Explanation: 
Name of identifier cannot be register Pseudo variables
Question 2
What will be the output of the following program -
#include<stdio.h>
int main(){
    int ivar = 15;
    int ivar = 20;
    printf("%d",ivar);
    return 0;
}
A
20
B
15
C
Compile Error
D
Run Time Error
Question 2 Explanation: 
Name of identifier cannot be exactly same as of name of another identifier within the scope of the function
Question 3
M_PI is constant in C Programming. Are you agree with this statement -
#include<stdio.h>
int main(){
    int M_PI=25;
    printf("%d",M_PI);
    return 0;
}

Statement : Above program will be compiled Successfully.

A
I am Not Agree
B
I Agree
Question 3 Explanation: 
M_PI is constant declared in math.h header file and in the above program we have not included math.h header file.
Question 4
Which value will be printed on the screen ?
int i = 314.562 * 150;
Consider Borland C/C++ Compiler.
A
47100
B
47184
C
None of these
D
Garbage Value
Question 4 Explanation: 
In Borland C/C++ Compiler this multiplication exceeds the limit.
Question 5
What will be printed on the screen if we print the variable name ?
name = ‘Suraj’ ;
A
uraj
B
Suraj
C
S
D
Compiler Error
Question 5 Explanation: 
Character can hold single value only.
Question 6
#include<stdio.h>
int main(){
    int M-PI=25;
    printf("%d",M_PI);
    return 0;
}
Find out error in the above code.
A
M-PI cannot be declared as it is One of the C Constant.
B
None of these
C
Variable Declaration is Illegal
D
All Characters in the Variable should not be in Capital Case.
Question 6 Explanation: 
Special Characters are not allowed.
Question 7
What will be the output of the following code ?
int main()
{
        int num,OS_Solaris,OS_Windows,OS_HP-UX;
        printf("Enter the number (1-3):\n");
        scanf("%d",&num);
        switch(num)
        {
                case 1:
                        OS_Solaris = 20;
                        break;
                case 2:
                        OS_Windows = 30;
                        break;
                case 3:
                        OS_HP-UX = 40;
                        break;
                default:
                        printf("Hmm! only 1-3 :-)\n");
                        break;
        }
        return 0;
}
Consider num entered is 3.
A
Compile Error will make compilation unsuccessful,
B
OS_HP-UX = 40
will be executed.
C
Cannot Execute Switch Case Statement
D
None of these
Question 7 Explanation: 
Special Symbols are not allowed while declaring identifier.
Question 8
Each C Program can have n number of variables.
A
False
B
True
Question 9
In C Programming we can declare variable at any position but just before using it.
A
True
B
False
Question 9 Explanation: 
C Programming does not allow you to write Variable declaration statement at any position.
Question 10
C Programming allows you to declare n variables in same statement separated by comma !!
A
False
B
True
There are 10 questions to complete.