Programming in C MCQ Quiz in मल्याळम - Objective Question with Answer for Programming in C - സൗജന്യ PDF ഡൗൺലോഡ് ചെയ്യുക
Last updated on Mar 8, 2025
Latest Programming in C MCQ Objective Questions
Top Programming in C MCQ Objective Questions
Programming in C Question 1:
‘C’ is a _________.
Answer (Detailed Solution Below)
Programming in C Question 1 Detailed Solution
Option 2 is correct.
C language stands between low-level and high-level language because it can create system-level programs for the operating system as like low-level languages, but it provides more abstraction than a low-level language.
C can also create application programs like high-level languages. C also have great readability and machine independence features like high-level languages. Consequently, C is a middle-level language.
Additional Information
- Low-level languages are those which are designed according to the machine and work according to the processor. It is similar to machine instruction.
- An assembly language is a low-level programming language in which there is a very strong correspondence between the program's statements and the architecture's machine code instructions
- A machine language is a binary code and binary code is a sequence of instructions and operands in binary that list the exact representation of instructions as they appear in computer memory
Programming in C Question 2:
Which is not the valid identifier in C++?
Answer (Detailed Solution Below)
Programming in C Question 2 Detailed Solution
extern is not a valid identifier in C++. Because it is a keyword.
- Combination of letter (A-Z) and digit (0-9) are used as identifier but identifier should not start with digit
Example: ext321ern and extern21 are valid identifier
- extern is a reserved word (keyword) in C++ programming language, hence it cannot be used as an identifier
- Underscore “_” is counted as a letter so it can be used as a variable name
- extern is a reserved word (keyword) in C++ but _extern is not reserved hence could be used as a variable name
e.g. int extern; / is not a valid variable name
Additional Information
Extern:-
The variables declared using keyword extern are called global variables.
These variables can be accessed throughout the program.
Keyword extern is used to declare a variable as a global variable inside any function.
Syntax is :
Extern datatype variable_name;
Answer (Detailed Solution Below)
Programming in C Question 3 Detailed Solution
- Zero(0) appended in the beginning of an integer data type, says that variable ‘a’ is explicitly assign a octal constant
- It is used as a conversion specifier for decimal, 42 in octal number will get converted into decimal number; (42)(8)= (4× 8)+2=34
Programming in C Question 4:
Consider the statement
int val[2] [4] = {1, 2, 3, 4, 5, 6, 7, 8};
What is the array declaration in the row-major order if its corresponding value is 4?
Answer (Detailed Solution Below)
Programming in C Question 4 Detailed Solution
int val[2] [4] = {1, 2, 3, 4, 5, 6, 7, 8} is a 2- dimensional array
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
treating the array declaration in the row-major ‘4’ comes under the first row and fourth column which has the index value val [0] [3] hence (d) is correct option.
Programming in C Question 5:
What will be the output of the following code?
int fun(int n)
{
static int v = 0;
if (n >= 5) return 1;
v=n;
return fun(n+1) + v;
}
int main() {
printf("output is %d", fun(1));
return 0;
}
Answer (Detailed Solution Below)
Programming in C Question 5 Detailed Solution
The correct answer is 17.
Solution:-
At the last 1 return to the fun(5).
fun(5)+4=5, 5 is return to fun(4).
fun(4)+4=9, 9 is return to fun(3).
fun(3)+4=13, 13 is return to fun(2).
fun(2)+4=17, 17 is return to fun(1)
Now understand the working of the recursion function:-
- n=1 v=0
- n=2 v=1
- n=3 v=2
- n=4 v=3
- n=5 v=4, now n>=5 conditions true hence the function returns 1.
Finally, the fun() returns 17 to the printf().
Note:-
- The v=4 is used everywhere because it is a static variable.
- Recursion questions can be solved in many ways like with stack, tree, etc.
- But I prefer to do such questions with the tree.
- One thing here you should notice is that v is a static variable means memory is allocated only once at compile time.
Programming in C Question 6:
Consider the below given code.
#include
int main()
{
static int x[ ] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int i;
for(int i = 2; i < 7; i++)
x[x[i]] = x[i];
int sum = 0;
for(int j = 0; j < 10;j++)
sum = sum + x[j];
printf("%d",sum);
}
The value printed of sum is ____.
Answer (Detailed Solution Below) 52
Programming in C Question 6 Detailed Solution
Array:
Index |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|
Value |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
|
value of i (i<7) |
operation |
value modified |
2 |
x[x[2]] = x[2]; x[3] = 3; |
a[3] = 3 |
3 |
x[x[3]] = x[3] x[3] = x[3] x[3] = 3 |
a[3] = 3 |
4 |
x[x[4]] = x[4] x[5] =5 |
a[5] = 5 |
5 |
x[x[5]] = x[5] x[5] =5 |
a[5] = 5 |
6 |
x[x[6]] = x[6] x[7] = 7 |
x[7] = 7 |
Modified Array:
Index |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
Value |
1 |
2 |
3 |
3 |
5 |
5 |
7 |
7 |
9 |
10 |
sum = 1 + 2 + 3 + 3 + 5 + 5 + 7 + 7 + 9 + 10 = 52.
Output: 52.
Programming in C Question 7:
Consider the following C program.
# include
struct Ournode {
char x, y, z ;
} ;
int main ( ) {
struct Ournode p = {‘1’, ‘0’, ‘a’ + 2} ;
struct Ournode *q = &p;
printf (“%c, %c”, *( (char*) q + 1) , *( (char*) q + 2) ) ;
return 0 ;
}
The output of this program is:
Answer (Detailed Solution Below)
Programming in C Question 7 Detailed Solution
Character ‘a’ has ASCII value 97, adding 2 will result in 99, which is the ASCII value for ‘c’.
Hence dereferencing q + 1 and q + 2 will give 0 and c respectively.
char x = 'a' + 2, that is, x == 'c'
So, p={'1','0','c'};
*((char*)q+1) = *(address of data '1' + 1) = *(address of data '0') = 0;
*((char*)q + 2) = *(address of data '1' + 2) = *(address of data 'c') = c;
printf("%c, %c",*((char*)q+1),*((char*)q+2)) will print 0, c.
Programming in C Question 8:
If value of p is 10 then what is the value of m+n:
{
int m = ++p;
int n = p--;
}
Answer (Detailed Solution Below)
Programming in C Question 8 Detailed Solution
Concept:-
Meaning of i++: [post increment]
First, we read i then after reading the value of i we are going to increment i this is nothing but post-increment.
Meaning of ++i: [pre increment]
First we increment i then we read the value of I, this is nothing but pre-increment:
Analysis:-
- int m = ++p; /before storing the value increments the value of p by 1 therefore m = 11 and p = 11
- int n = p--; /value of p is stored in n then it is decremented by 1 therefore n = 11 and p = 10
- m + n = 11 + 11 = 22
Note:-
p = i++ , Here i value first stored in p and then i value incremented.
p= ++i , here i value first incremented and then stored in p.
Programming in C Question 9:
What will be the output of the following C program:(consider int is of 4 bytes and array (arr) starting address is 2000 in decimal )
Answer (Detailed Solution Below)
2040
Programming in C Question 9 Detailed Solution
Answer: Option 3
Explanation:
- arr denote the Base address of the array.
- &arr will not work the same way as some of you think.
printf("%ld\n",arr+1);
- In the First printf ; arr +1 , addition of 1 resulted in an address increment of 1 int data size hence 2000 + 4 = 2004 will be printed
printf("%ld",(&arr + 1));
- &arr will return a pointer to the whole array of 10 int, addition of 1 resulted in an address with an increment of 4 x 10 = 40 and hence 2040 will be printed in next line.
Hence Option 3 is the correct answer.
Programming in C Question 10:
Consider the following C program:
#include
int main ( )
{
int arr [ ] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 5}, *ip = arr + 4;
printf (“ % d \n”, ip[1]);
return 0;
}
The number that will be displayed on execution of the program is _________.Answer (Detailed Solution Below) 6
Programming in C Question 10 Detailed Solution
int *ip = arr + 4 /ip is a integer pointer pointing to 5 element of the array
ip[1] = *(ip + 1xsizeofint) = *(address of 6th element) = 6