# C Programming Quiz: Practice Exam!

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
| By Vedant Two
V
Vedant Two
Community Contributor
Quizzes Created: 1 | Total Attempts: 342
Questions: 50 | Attempts: 355

Settings

.

• 1.

### #include<stdio.h> main()  {       enum { abesit, abesec=4,akgec};       printf("%d %d", abesit, akgec); }

• A.

0 1

• B.

0 5

• C.

0 4

• D.

Compile error

B.  0 5
Explanation
The code defines an enumeration with three values: abesit, abesec, and akgec. The value of abesit is 0, abesec is 4, and akgec is 5. The printf statement then prints the values of abesit and akgec, which are 0 and 5 respectively.

Rate this question:

• 2.

### #include<stdio.h> int xstrlen(char *s) {    int length = 0;        while(*s!='\0')    {length++; s++;}    return (length); }    int main() {    char d[] = "DATASTRUCTURE";         printf("Length = %d\n", xstrlen(d));    return 0; }

• A.

Code returns error

• B.

Code returns the length 13

• C.

Code returns the length 12

• D.

Code returns the length 0

B. Code returns the length 13
Explanation
The given code calculates the length of a string using the xstrlen function. The function iterates through the characters of the string until it reaches the null character '\0', incrementing the length variable each time. In the main function, a string "DATASTRUCTURE" is passed to the xstrlen function, and the returned length is printed. Since the string has 13 characters, including the null character, the code returns the length 13.

Rate this question:

• 3.

### #include <stdio.h> int main()  {      char a[] = { 'D, 'A', 'T', 'A' };      char* ppp = &a[0];      *ppp++; // Line 1      printf("%c %c ", *++ppp, --*ppp); // Line 2  }

• A.

D T

• B.

A D

• C.

D A

• D.

T D

D. T D
Explanation
The program initializes an array 'a' with the characters 'D', 'A', 'T', 'A'. Then, it declares a pointer 'ppp' and assigns it the address of the first element of the array.

In Line 1, the expression '*ppp++' increments the pointer 'ppp' to point to the next element in the array, but dereferences the original pointer to get the value 'D'.

In Line 2, the expression '*++ppp' increments the pointer 'ppp' again to point to the next element in the array, and then dereferences it to get the value 'T'. The expression '--*ppp' decrements the value at the current pointer location, resulting in 'D'.

Therefore, the output is 'T D'.

Rate this question:

• 4.

### #include<stdio.h> Void main()  { While(! printf("while loop is amazing one") ; }

• A.

Compilation error

• B.

While loop is amazing one

• C.

Runtime error

• D.

none of the above

A. Compilation error
Explanation
The given code will result in a compilation error. This is because the condition inside the while loop is not a valid expression. The printf() function returns the number of characters printed, so using it as a condition in the while loop is not valid syntax.

Rate this question:

• 5.

### #include<stdio.h> main()  { int n=8; int f(int n); printf("%d", f(n)); } int f(int n)  { if(n>0)  return (n+f(n-2)); }

• A.

10

• B.

20

• C.

30

• D.

Error

B. 20
Explanation
The program is using recursion to calculate the value of f(n). In the main function, n is initialized to 8 and then passed to the f function. In the f function, it checks if n is greater than 0. Since 8 is greater than 0, it returns the sum of n and f(n-2), which is f(6). This process continues until n becomes 0, at which point the recursion stops. Therefore, the final value returned by f(8) is 20.

Rate this question:

• 6.

### #include<stdio.h> main()  { printf(3+"Good morning "); }

• A.

Good morning

• B.

Morning

• C.

Good

• D.

D morning

D. D morning
Explanation
The code snippet uses pointer arithmetic to print the string "Good morning " starting from the third character. The pointer arithmetic `3+"Good morning "` moves the pointer forward by 3 characters, skipping the first 3 characters "Goo". Therefore, it prints "d morning".

Rate this question:

• 7.

### #include<stdio.h> #include<conio.h> void main()  { char s[]="ghost"; printf("%d",sizeof(s)); getch(); }

• A.

5

• B.

6

• C.

4

• D.

Error

B. 6
Explanation
The correct answer is 6. The sizeof() function in C returns the size in bytes of the variable or data type passed as an argument. In this case, the argument is the character array "s" which has a size of 5 characters. However, the sizeof() function also includes the null character '\0' at the end of the string, so the total size is 6 bytes. Therefore, the output of the printf statement is 6.

Rate this question:

• 8.

### #include<stdio.h> #include<conio.h> void main()  { printf("\n yo"); printf("\b ghost"); printf("\r hy"); getch(); }

• A.

Hy

• B.

Yo

• C.

Hyghost

• D.

None of the above

C. Hyghost
Explanation
The given code is a C program that uses the printf function to print out strings. The program first prints " yo" which will be displayed as " yo" in the output. Then it uses the escape sequence \b to move the cursor back one position, so the next string " ghost" will overwrite the space and be displayed as " ghost". Next, it uses the escape sequence \r to move the cursor to the beginning of the line, so the next string " hy" will overwrite the previous strings and be displayed as " hy". Finally, the program waits for user input with the getch function. Therefore, the output will be "hyghost".

Rate this question:

• 9.

### #include<stdio.h> int main(){    int count, temp, i, j, number[30];    printf("How many numbers are u going to enter?: ");    scanf("%d",&count);    printf("Enter %d numbers: ",count);    for(i=0;i<count;i++)    scanf("%d",&number[i]);    for(i=count-2;i>=0;i--){       for(j=0;j<=i;j++){         if(number[j]>number[j+1]){            temp=number[j];            number[j]=number[j+1];            number[j+1]=temp;         }       }    }    printf("Sorted elements: ");    for(i=0;i<count;i++)       printf(" %d",number[i]);    return 0; }

• A.

Error

• B.

bubble sort

• C.

quick sort

• D.

insertion sort

B.  bubble sort
Explanation
The given code is implementing the bubble sort algorithm. It takes input from the user, stores it in an array, and then uses nested loops to compare and swap adjacent elements if they are in the wrong order. This process is repeated until the array is sorted in ascending order. Finally, the sorted elements are printed. Therefore, the correct answer is "bubble sort".

Rate this question:

• 10.

### #include <stdio.h> void main() { char *s= "data"; char *p = s; printf("%c%c", p[1],s[2]); }

• A.

At

• B.

Data

• C.

Ata

• D.

None of the above

A. At
Explanation
The code initializes a character pointer 's' to point to the string "data". Then, another character pointer 'p' is initialized to point to the same memory location as 's'. The printf statement prints the characters at index 1 of 'p' (which is 'a') and index 2 of 's' (which is 't'). Therefore, the output will be "at".

Rate this question:

• 11.

### #include <stdio.h> void c( int[] ); int main() { int ary[4] = {1, 2, 3, 4}; c(ary); printf("%d ", ary[0]); } void c(int p[4]) { int i = 1; p = &i; printf("%d ", p[0]); }

• A.

1 1

• B.

1 2 3 4

• C.

2 3

• D.

none of the above

A.  1 1
Explanation
The correct answer is "1 1".

In the main function, an array "ary" is declared and initialized with values {1, 2, 3, 4}. The function "c" is then called with the array "ary" as the argument.

In the "c" function, a local variable "i" is declared and assigned the value 1. The parameter "p" is then assigned the address of "i". The statement "printf("%d ", p[0]);" prints the value at the memory location pointed to by "p", which is 1.

Back in the main function, the statement "printf("%d ", ary[0]);" prints the value at the first index of the array "ary", which is also 1.

Rate this question:

• 12.

### #include<stdio.h> void main()  { float b=0.45; if(b<0.45)  printf("wow"); else printf ("how"); }

• A.

wow

• B.

How

• C.

Compilation error

• D.

Syntax error

A.  wow
Explanation
The given code declares and initializes a float variable b with the value 0.45. The if statement checks if b is less than 0.45. Since b is equal to 0.45, the condition is false and the program executes the else block. Therefore, the output will be "how".

Rate this question:

• 13.

### #include<stdio.h> void main()  { int I; for(I=1;I<=5;I++)  { if(I==3)  { break; } printf("%d",I); }}

• A.

1 2

• B.

1 2 3

• C.

1 2 3 4 5

• D.

none of the above

A.  1 2
Explanation
The code includes a for loop that iterates from 1 to 5. Inside the loop, there is an if statement that checks if the value of I is equal to 3. If it is, the break statement is executed, which terminates the loop. Therefore, when I is equal to 3, the loop is stopped and the program moves on to the next line of code after the loop. Before the break statement is executed, the printf statement is executed, which prints the value of I. So, the output will be 1 2.

Rate this question:

• 14.

### #include<stdio.h> void main()  { int I=65; char J='A'; if(I==J)  { printf("hey"); } else { printf("hii"); } }

• A.

hey

• B.

hii

• C.

none of the above

• D.

Error

A.  hey
Explanation
The code compares the integer value 65 with the ASCII value of the character 'A', which is also 65. Since the values are equal, the condition in the if statement is true, and "hey" is printed.

Rate this question:

• 15.

### #include <stdio.h>  int main()  {      int* data;     *data= 9;     printf("%d", *data);      return 0;  }

• A.

Compilation error

• B.

Runtime error

• C.

9

• D.

A. Compilation error
Explanation
The given code will result in a compilation error. This is because the pointer variable "data" has not been assigned any memory before dereferencing it using the "*" operator. This leads to undefined behavior and a compilation error.

Rate this question:

• 16.

### #include<stdio.h>int main() {int x;For(x= -1;x<=10;x++) {if(x<5) Continue;elsebreak;printf("abc");}return 0;}

• A.

Infinite times

• B.

11 times

• C.

0 times

• D.

10 times

C.  0 times
Explanation
The code starts with initializing the variable x to -1. Then, it enters a for loop that runs as long as x is less than or equal to 10. Inside the loop, there is an if condition that checks if x is less than 5. If it is, the loop continues to the next iteration. If it is not, the loop breaks and the program exits the loop. However, the printf statement that prints "abc" is placed after the break statement, so it will never be executed. Therefore, the correct answer is 0 times.

Rate this question:

• 17.

### #include<stdio.h>int main() {int i=0;For(; i<=5;i++) printf("%d", i);return 0;}

• A.

6

• B.

1,2,3,4

• C.

5

• D.

0,1,2,3,4,5

A.  6
Explanation
This code snippet is a simple C program that uses a for loop to print the values of i from 0 to 5. The loop starts with i=0 and continues until i

Rate this question:

• 18.

### #include<stdio.h>int main() {int a=500, b=100, c;if(! a>=400) b=300;printf("b=%d c=%d \n", b, c);return 0;}

• A.

b=100 c= garbage

• B.

B=300 c= garbage

• C.

b=100 c=200

• D.

B=300 c=200

D. B=300 c=200
Explanation
In this code, the condition in the if statement is "! a>=400". The "!" operator is a logical negation operator, so it will negate the result of the expression "a>=400". Since a is equal to 500, the expression "a>=400" is true, and negating it will make it false. Therefore, the code inside the if statement will not be executed and the value of b will remain 100. The value of c is not initialized in the code, so it will contain garbage value. The printf statement will print "b=100 c=garbage".

Rate this question:

• 19.

### #include<stdio.h>int main() {usigned int i= 65535;/*Assume 2byte integer*/ While(i++! =0) printf("%d", ++i);printf("\n");return 0;}

• A.

0 1 2...65535

• B.

Infinte Loop

• C.

0 1 2...32767-32766-32765-1 0

• D.

No Output

B. Infinte Loop
Explanation
The code starts with the variable i initialized to 65535. The while loop condition checks if i incremented by 1 is not equal to 0. Since i is initially 65535, the condition is true and the loop is entered. Inside the loop, i is incremented again before being printed. This process continues indefinitely, incrementing i and printing it until it reaches the maximum value for an unsigned integer (65535) and then wraps around to 0. Therefore, the loop will continue infinitely, printing the numbers from 0 to 65535 repeatedly.

Rate this question:

• 20.

### #include<stdio.h>int main() {int x=3;float y=3.0;if(x==y) printf("x and y are not equal");return 0;}

• A.

No Output

• B.

X and y are not equal

• C.

x and y are equal

• D.

Unpredictable

C.  x and y are equal
Explanation
In this code, the variable x is an integer with a value of 3, and the variable y is a float with a value of 3.0. The if statement compares the values of x and y using the equality operator (==). Since the values of x and y are equal, the condition of the if statement is true. Therefore, the code inside the if statement will execute, which is the printf statement that prints "x and y are equal". Hence, the correct answer is "x and y are equal".

Rate this question:

• 21.

### #include<stdio.h>int main() {Chat ch;if(Ch= printf(" ")) printf(" It matters \n") ;return 0;}

• A.

It Matters

• B.

It doesn't Matters

• C.

Matters

• D.

No Output

B. It doesn't Matters
Explanation
The correct answer is "It doesn't Matters". In the given code, the variable "ch" is of type "Chat" which is not a valid data type in C. It should be "char" instead. Also, the if statement is assigning the value of the expression "printf(" ")" to "Ch" instead of comparing it. Since the expression inside the printf function is just a space, it will return 1 (true) and the if statement will be true. Therefore, the code will print "It matters" and the correct answer is "It doesn't Matters".

Rate this question:

• 22.

### #include<stdio.h>int main() {int a[5]={5,1,15,20,25};int i,j,m;i= ++a[1];j= a[1]++;m= a[i++];printf("%d%d%d", i,j,m) ;return 0;}

• A.

1,2,15

• B.

2,3,20

• C.

2,1,15

• D.

3,2,15

D. 3,2,15
Explanation
The code initializes an array "a" with values {5, 1, 15, 20, 25}.

The variable "i" is assigned the value of the second element of the array (1) after incrementing it by 1, so i becomes 2.

The variable "j" is assigned the value of the second element of the array (1), and then the value of the second element is incremented by 1, so j becomes 1.

The variable "m" is assigned the value of the element at index i (2), which is 15. Then, the value of i is incremented by 1, so i becomes 3.

Finally, the values of i, j, and m are printed, resulting in the output: 3, 2, 15.

Rate this question:

• 23.

### What is the output of this program? #include<stdio.h>Void main() {int a=b=c=10;a=b=c=50;printf("\n%d%d%d", a,b,c);}

• A.

Three Garbage Values

• B.

10 10 10

• C.

Compile time Error

• D.

50 50 50

C. Compile time Error
Explanation
The program will result in a compile-time error because the "Void" keyword should be "void" (lowercase "v"). This error prevents the program from running correctly and producing any output.

Rate this question:

• 24.

### What will be the ouput of this following c code? #include <stdio.h> void main() { int a[4] = {1, 2, 3,4}; int *p = a; printf("%p\t%p", p, a); }

• A.

• B.

• C.

Compile time error

• D.

Nothing

Explanation
The code declares an integer array 'a' with 4 elements and initializes it with values 1, 2, 3, and 4. It also declares a pointer variable 'p' and assigns the address of the first element of 'a' to it. The printf statement prints the value of 'p' and 'a', which are both addresses. Since 'p' is assigned the address of the first element of 'a', both 'p' and 'a' will have the same address. Therefore, the output will be the same address printed twice.

Rate this question:

• 25.

### Which bitwise operator is suitable for turning off a the particular bit in a number?

• A.

&& operator

• B.

& operator

• C.

|| operator

• D.

! operator

B. & operator
Explanation
The & operator is suitable for turning off a particular bit in a number. This operator performs a bitwise AND operation between two operands. When used with a specific bit pattern, it can be used to turn off a particular bit by setting it to 0 while leaving the other bits unchanged.

Rate this question:

• 26.

### Choose the invalid identifier from the below.

• A.

Int

• B.

volatile

• C.

DOUBLE

• D.

.__0__

B.  volatile
Explanation
The invalid identifier in the given options is "volatile". In programming, an identifier is a name used to identify a variable, function, or any other user-defined item. However, "volatile" is a valid keyword in many programming languages, used to indicate that a variable's value can be modified by external influences. It cannot be used as an identifier for naming variables or other entities.

Rate this question:

• 27.

### In the given below code, the P2 is [Typedef int *ptr;

• A.

Integer

• B.

Integer pointer

• C.

Both, Integer & Integer pointer

• D.

None of above

B. Integer pointer
Explanation
The correct answer is "Integer pointer" because the code snippet defines a typedef for a pointer to an integer. This means that the variable P2 will be a pointer that can hold the memory address of an integer variable.

Rate this question:

• 28.

### What will be the output of the following C code? #include <stdio.h> int main() { printf("%d ", 1); goto l1; printf("%d ",2); } void foo() { l1 : printf("3 ", 3); }

• A.

1 2 3

• B.

1 3

• C.

1 3 2

• D.

Compilation error

D. Compilation error
Explanation
The code will result in a compilation error because the label "l1" is defined inside the function "foo" and cannot be accessed outside of it. Therefore, the "goto" statement in the main function will not be able to find the label "l1" and will result in a compilation error.

Rate this question:

• 29.

### Associativity of unary operator is from _________ to __________.

• A.

Right to Left

• B.

Left to right

A. Right to Left
Explanation
The associativity of unary operators is from right to left. This means that if there are multiple unary operators in a single expression, they will be evaluated from right to left. For example, in the expression "-5!", the unary operator "-" is evaluated first, followed by the factorial operator "!".

Rate this question:

• 30.

### Which of the following operator has lowest precedence amongst all the operators ?

• A.

Comma

• B.

Logical AND

• C.

Plus

• D.

Modulus

A. Comma
Explanation
The comma operator has the lowest precedence among all the operators. This means that it has the least priority when it comes to evaluating expressions. The comma operator allows multiple expressions to be evaluated sequentially, from left to right, and the value of the entire expression is the value of the rightmost expression. It is commonly used in for loops or function calls where multiple expressions need to be evaluated in a specific order.

Rate this question:

• 31.

### Which of the following % operation is invalid?

• A.

2 % 4;

• B.

2 % 4l;

• C.

2 % 4f;

• D.

Both 2 % 4l; and 2 % 4f;

C. 2 % 4f;
Explanation
The % operator in Java is used to find the remainder of a division operation. It can be used with integers, longs, and floats. However, it cannot be used with floats directly. In the given options, all the other operations are valid except for 2 % 4f. This is because the % operator cannot be used with floats, so 2 % 4f is an invalid operation.

Rate this question:

• 32.

### How many loops are there in C?

• A.

1

• B.

2

• C.

3

• D.

4

C. 3
Explanation
In the C programming language, there are three types of loops: the for loop, the while loop, and the do-while loop. These loops allow the program to repeat a block of code multiple times based on a specified condition. Therefore, the correct answer is 3, as there are three loops in C.

Rate this question:

• 33.

### When C Language was invented?

• A.

1972

• B.

1970

• C.

1978

• D.

1979

A. 1972
Explanation
C Language was invented in 1972.

Rate this question:

• 34.

### What is the meaning of the below lines? void sum (int, int);

• A.

Sum is function which takes int arguments

• B.

Sum is a function which takes two int arguments and returns void

• C.

it will produce compilation error

• D.

Can't comment

B. Sum is a function which takes two int arguments and returns void
Explanation
The correct answer is "sum is a function which takes two int arguments and returns void." This is because the given lines "void sum (int, int);" indicate the declaration of a function named "sum" that takes two integer arguments and returns nothing (void).

Rate this question:

• 35.

### The concept of two functions with same name is known as?

• A.

• B.

• C.

Function Overriding

• D.

Function renaming

Explanation
Function overloading is the concept of having multiple functions with the same name but different parameters. This allows programmers to define multiple functions with the same name but with different behaviors based on the type and number of arguments passed to them. This helps in writing more concise and readable code by providing a single name for similar operations that can be performed on different data types or with different parameter combinations.

Rate this question:

• 36.

• A.

Math.h

• B.

mathio.h

• C.

String.h

• D.

Ctype.h

B.  mathio.h
• 37.

### Libray function getch() belongs to which header file?

• A.

Stdio.h

• B.

conio.h

• C.

Stdlib.h

• D.

Stdlibio.h

B.  conio.h
Explanation
The correct answer is conio.h. The conio.h header file is used in C programming language to provide console input/output functions. The getch() function is one of the functions provided by this header file, which is used to read a single character directly from the console without echoing it.

Rate this question:

• 38.

### Library function pow() belongs to which header file?

• A.

Mathio.h

• B.

Math.h

• C.

Square.h

• D.

Stdio.h

B. Math.h
Explanation
The library function pow() belongs to the math.h header file. This header file provides various mathematical functions, including the pow() function, which is used to calculate the power of a number. Therefore, to use the pow() function in a program, the math.h header file needs to be included.

Rate this question:

• 39.

### Which of the following has a global scope in the program?

• A.

Formal parameters

• B.

Constants

• C.

Macros

• D.

Local variables

C. Macros
Explanation
Macros have a global scope in a program. Macros are preprocessor directives that are defined using the #define statement and are replaced with their corresponding values during the preprocessing stage. Since macros are defined at the global level and can be accessed from anywhere in the program, they have a global scope. On the other hand, formal parameters, constants, and local variables have a limited scope and are only accessible within their respective functions or blocks.

Rate this question:

• 40.

### Predict the output of the following code segment:   int main() { int array[10] = {3, 0, 8, 1, 12, 8, 9, 2, 13, 10}; int x, y, z; x = ++array[2]; y = array[2]++; z = array[x++]; printf("%d %d %d", x, y, z); return 0; }

• A.

10 9 10

• B.

9 10 9

• C.

9 9 10

• D.

None of the above

A. 10 9 10
Explanation
The code segment initializes an array with 10 elements. The variable 'x' is assigned the value of the third element in the array after incrementing it. The variable 'y' is assigned the value of the third element in the array before incrementing it. The variable 'z' is assigned the value of the element in the array at index 'x' after incrementing 'x'. Finally, the values of 'x', 'y', and 'z' are printed, which are 10, 9, and 10 respectively.

Rate this question:

• 41.

### Predict the output of the following code segment:   int main() { int number1 = -17; int number2 = -5; int result = number1 % number2; printf("%d",result); return 0; }

• A.

2

• B.

-2

• C.

3,4

• D.

-3,4

B. -2
Explanation
The code segment calculates the remainder when number1 is divided by number2 using the modulus operator (%). In this case, number1 is -17 and number2 is -5. When -17 is divided by -5, the remainder is -2. Therefore, the output of the code segment is -2.

Rate this question:

• 42.

### Out of the following declarations, which one is invalid?

• A.

Short a = 10;

• B.

Unsigned short b = 20;

• C.

Long double c = 30;

• D.

Long short d = 40;

D. Long short d = 40;
Explanation
The declaration "long short d = 40;" is invalid because there is no data type called "long short" in C++. The "long" and "short" keywords cannot be used together in a declaration.

Rate this question:

• 43.

### Who developed C languages?

• A.

Ken Thomson

• B.

Peter Norton

• C.

Von Neuman

• D.

Dennis Ritchie

D. Dennis Ritchie
Explanation
Dennis Ritchie developed the C programming language. He created C in the early 1970s at Bell Labs, along with his colleague Ken Thompson. C became widely popular due to its simplicity, efficiency, and portability, and it played a significant role in the development of modern operating systems and software. Ritchie's contributions to the field of computer science extend beyond C, as he also co-developed the Unix operating system and made significant contributions to the development of the programming language B, which preceded C.

Rate this question:

• 44.

### What is the length null string?

• A.

0

• B.

1

• C.

2

• D.

3

A. 0
Explanation
The length of a null string is 0 because a null string does not contain any characters. Therefore, it has no length or size.

Rate this question:

• 45.

### Which of the following functions can be used to increase the size of dynamically allocated array?

• A.

realloc()

• B.

Calloc()

• C.

Malloc()

• D.

A.  realloc()
Explanation
The realloc() function can be used to increase the size of a dynamically allocated array. It allows for the reallocation of memory for an existing block, which means that it can be used to resize an array by allocating more memory for it. This function takes two arguments: a pointer to the previously allocated memory block and the new size in bytes. It returns a pointer to the newly allocated memory block, which can be used to access the resized array.

Rate this question:

• 46.

### What is the default return type of a function?

• A.

Void

• B.

Int

• C.

Char

• D.

Float

B. Int
Explanation
The default return type of a function is "int". This means that if a function does not explicitly specify a return type, it will default to returning an integer value.

Rate this question:

• 47.

### What is the output of the below program? int main() { int i,j,count; count=0; for(i=0; i<5; i++); {      for(j=0;j<5;j++);     {         count++;     } } printf("%d",count); return 0; }

• A.

55

• B.

54

• C.

1

• D.

0

C. 1
Explanation
The program contains two nested for loops. The first loop iterates from 0 to 4, and the second loop also iterates from 0 to 4. However, both loops have a semicolon immediately after the condition, which means that the loops are empty and do not have any statements inside them. Therefore, the count variable is incremented only once outside the loops, resulting in a value of 1. This value is then printed as the output.

Rate this question:

• 48.

### What is the output of the below program? int main() { int i,j,k,count; count=0; for(i=0;i<5;i++) {    for(j=0;j<5;j++)    {       count++;    } } printf("%d",count); return 0; }

• A.

5

• B.

10

• C.

25

• D.

50

C. 25
Explanation
The program uses nested for loops to iterate through two variables, i and j, both ranging from 0 to 4. Within the inner loop, the count variable is incremented by 1 each time. Since the inner loop is executed 5 times for each iteration of the outer loop, the count variable is incremented a total of 25 times. Therefore, the output of the program is 25.

Rate this question:

• 49.

### What is the output of the below program? int main() { const int a = 10; printf("%d",++a); return 0; }

• A.

11

• B.

10

• C.

Compilation error

• D.

0

C. Compilation error
Explanation
The program is trying to increment the value of a, which is declared as a constant using the "const" keyword. Constants cannot be modified once they are assigned a value. Therefore, attempting to increment a constant variable will result in a compilation error.

Rate this question:

• 50.

### Which of the following ways is correct to include the header file in the C program?

• A.

#include<stdio.h>

• B.

#include"stdio.h"

• C.

Both A & B

C.  Both A & B
Explanation
Both A and B are correct ways to include the header file in a C program.

In option A, "#include" is used to include the standard input/output header file. This is the most commonly used way to include header files in C programs.

In option B, "#include"stdio.h"" is used to include the same header file. This method is used when the header file is located in the current directory or a specific directory relative to the current directory.

Both methods achieve the same result of including the specified header file in the C program.

Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

• Current Version
• Mar 21, 2023
Quiz Edited by
ProProfs Editorial Team
• Sep 04, 2020
Quiz Created by
Vedant Two

Related Topics