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; }
No | |
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; }
20 | |
15 | |
Compile Error | |
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.
I am Not Agree | |
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.
47100 | |
47184 | |
None of these | |
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’ ;
uraj | |
Suraj | |
S | |
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.
M-PI cannot be declared as it is One of the C Constant. | |
None of these | |
Variable Declaration is Illegal | |
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.
Compile Error will make compilation unsuccessful, | |
OS_HP-UX = 40will be executed. | |
Cannot Execute Switch Case Statement | |
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.
False | |
True |
Question 9 |
In C Programming we can declare variable at any position but just before using it.
True | |
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 !!
False | |
True |
There are 10 questions to complete.