C Language Exam: Practice Quiz! Trivia

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Sunil Singhal
S
Sunil Singhal
Community Contributor
Quizzes Created: 4 | Total Attempts: 26,625
| Attempts: 1,691 | Questions: 50
Please wait...
Question 1 / 50
0 %
0/100
Score 0/100
1. Which of the follwing is a string

Explanation

The correct answer is "abcd" because it is enclosed in double quotation marks, which is the correct syntax for representing a string in many programming languages. The other options either lack the quotation marks or have mismatched quotation marks, making them invalid representations of a string.

Submit
Please wait...
About This Quiz
C Language Exam: Practice Quiz! Trivia - Quiz

This C language Exam: Practice Quiz! Trivia assesses foundational C programming skills through practical questions. It covers array operations, loop mechanics, memory management, and basic arithmetic in C,... see moreoffering learners a chance to sharpen their coding proficiency. see less

2. The maximum number of dimension an array can have in C language is

Explanation

The maximum number of dimensions an array can have in C language is not fixed and depends on the compiler being used. Different compilers may have different limits on the number of dimensions allowed for an array. Therefore, the correct answer is "compiler dependent".

Submit
3. C can be used on?

Explanation

The correct answer is "All of the above" because C is a programming language that can be used on multiple operating systems, including MS-DOS, Linux, and Windows. It is a versatile language that is not limited to a specific platform, allowing developers to write code that can run on different operating systems without major modifications.

Submit
4. C programs are converted into the machine language with the help of?

Explanation

C programs are converted into machine language with the help of a compiler. A compiler is a software tool that translates the entire C program into machine code that can be directly executed by the computer's processor. It analyzes the source code, checks for errors, and generates the corresponding machine code instructions. This process is known as compilation and is essential for the execution of C programs on a computer.

Submit
5. How would you copy the name "Hello" to a character array (i.e. string) declared as char str[10];

Explanation

The correct answer is strcpy( str, "Hello" );. This function is used to copy a string from one location to another. In this case, it copies the string "Hello" to the character array str. The other options are incorrect. strcat(str, "Hello") would concatenate the string "Hello" to the existing string in str. printf( str, "Hello" ) is not a valid function call as printf is used for printing formatted output. str = "Hello" is also incorrect as you cannot assign a string directly to a character array.

Submit
6. Array subscripts in ‘C’ always start at

Explanation

In the programming language 'C', array subscripts always start at 0. This means that the first element of an array is accessed using the subscript 0, the second element with the subscript 1, and so on. This is a fundamental concept in 'C' and many other programming languages, where arrays are typically implemented as contiguous blocks of memory. Starting the subscripts at 0 allows for efficient memory access and indexing calculations.

Submit
7. Linux was developed mainly using C language. 

Explanation

Linux was developed mainly using the C language because C is a high-level programming language that allows for efficient and low-level programming. It provides direct access to memory and hardware, making it suitable for developing an operating system like Linux. Additionally, C is portable and can be easily adapted to different hardware architectures, which is crucial for an operating system that needs to run on various devices. Therefore, it is true that Linux was primarily developed using the C language.

Submit
8. The value within the [] brackets in an array declaration specifies

Explanation

The value within the [] brackets in an array declaration specifies the size of the array. It determines the number of elements that can be stored in the array.

Submit
9. What is the output of the following module sum=0; I=0; do{ sum+=I; I++; }while(I<=5); printf(“%d”, sum);

Explanation

The given module calculates the sum of numbers from 1 to 5 using a do-while loop. The variable 'sum' is initialized to 0 and 'I' is initialized to 0. Inside the loop, 'sum' is incremented by the value of 'I' and 'I' is incremented by 1. This process continues until 'I' becomes greater than 5. Finally, the value of 'sum' is printed using the printf statement. In this case, the final value of 'sum' would be 15, which is the correct answer.

Submit
10. What is the result of the expression ( 10/3 )*3+5%3 ?

Explanation

The expression (10/3) evaluates to 3.3333. Multiplying this by 3 gives us 9.9999. The modulus operator (%) calculates the remainder of dividing 5 by 3, which is 2. Adding 9.9999 and 2 gives us 11. Therefore, the result of the expression is 11.

Submit
11. Consider the array definition int num [10] = { 3 ,3 ,3 }; pick the correct answers

Explanation

The given array definition initializes an array called "num" with a size of 10 and assigns the first three elements with the value 3. Since array indices start from 0, the value of num[2] refers to the third element in the array, which is indeed 3. Therefore, the statement "the value of num[2] is 3" is correct.

Submit
12. Identify the loop construct:

Explanation

The correct answer is "while". The while loop construct is used to repeatedly execute a block of code as long as a certain condition is true. It first checks the condition and if it is true, the code inside the loop is executed. Once the code is executed, the condition is checked again and if it is still true, the code is executed again. This process continues until the condition becomes false.

Submit
13. Give the output of the following program: #include < stdio.h > main() {int I=1; while (I < 5) {printf(“%d”, I); }} /* End of Main */

Explanation

The given program contains a while loop that will continue executing as long as the condition "I

Submit
14. Output of the below program #include<stdio.h> main() {int a,b=0; int c[10]={1,2,3,4,5,6,7,8,9,0 }; for(a=0;a<10;++a) b+=c[a]; printf(“%d”,b); }

Explanation

The program first initializes variables a and b, and an array c with 10 elements. It then enters a for loop that iterates from 0 to 9. Inside the loop, it adds the value of each element in array c to the variable b. After the loop, it prints the value of b, which is the sum of all elements in array c. Therefore, the output of the program will be 45.

Submit
15. The global variable can be declared

Explanation

Global variables can be declared before the main function in C programming. This means that the variable can be declared outside of any function, including the main function, and can be accessed by any function within the program. This allows the variable to have a global scope and be accessible throughout the entire program. By declaring the variable before the main function, it ensures that the variable is available for use by any function that may need it.

Submit
16. How many while statements are possible in do.... While loop?

Explanation

In a do...while loop, the condition is checked at the end of each iteration. This means that the loop will continue executing as long as the condition is true. Since the condition can be any boolean expression, there is no limit to the number of while statements that can be used in a do...while loop. Therefore, the correct answer is "any number".

Submit
17. Which of the following statements would read a single character from the keyboard and place the result in a character variable ‘ch’ defined as: char ch;

Explanation

The correct answer is "ch = getch( );". This statement uses the getch() function to read a single character from the keyboard and assigns the result to the character variable 'ch'.

Submit
18. What is the output of the following program main() {static int y; printf (“%d\n”, y); }

Explanation

The program declares a static variable "y" but does not assign any value to it. In C, static variables are automatically initialized to zero. Therefore, when the program prints the value of "y", it will output 0.

Submit
19. The maximum value that an integer constant can have is?

Explanation

The maximum value that an integer constant can have is 32767. This is because in most programming languages, integers are typically represented using a fixed number of bits, such as 16 bits. With 16 bits, the maximum value that can be represented is 2^(16-1) - 1, which equals 32767.

Submit
20. The storage area for register variables

Explanation

Processor registers are a small set of high-speed memory locations within the CPU that are used to store data that needs to be accessed quickly. Register variables are variables that are stored in these processor registers rather than in main memory. Storing variables in processor registers can result in faster access times compared to storing them in cache or main memory. Therefore, the correct answer is processor registers.

Submit
21. C language has been developed by?

Explanation

Dennis Ritchie is the correct answer because he is one of the main developers of the C programming language. Along with Ken Thompson, Ritchie created C at Bell Labs in the early 1970s. C became widely used and influential in the field of computer programming, serving as the foundation for many other programming languages. Ritchie's contributions to the development of C and his work on Unix have had a lasting impact on the field of computer science.

Submit
22. Count=0; for ( I=0;I<=10; I++) {if(I%2==0) count++; }printf(“%d”, count); Pick out the correct value for count

Explanation

The code initializes a variable "count" to 0. It then runs a loop from 0 to 10 (inclusive) and checks if each value of "I" is divisible by 2 (i.e., even). If "I" is even, it increments the "count" variable by 1. Finally, it prints the value of "count". Since there are 6 even numbers (0, 2, 4, 6, 8, 10) in the range, the correct value for "count" is 6.

Submit
23. Dynamic memory allocation in array results in

Explanation

Dynamic memory allocation in an array refers to the process of allocating memory for the array elements during the runtime of a program. This means that the memory for the array is allocated dynamically, based on the program's needs, rather than at compile time or any other specific time. The advantage of dynamic memory allocation is that it allows for flexibility in memory usage, as the size of the array can be determined and adjusted during runtime.

Submit
24. Printf (“\ “ well done\” ”); what will be the output of this statement

Explanation

The correct answer is " well done". This is because the backslashes (\) before and after the quotation marks (\") are escape characters, which indicate that the quotation marks should be treated as part of the string and not as string delimiters. Therefore, the output will include the quotation marks and the space before and after the words "well done".

Submit
25. A-C variable cannot start with?

Explanation

The correct answer is both (2) and (3). This means that a variable in programming cannot start with a number or a special symbol other than an underscore. Variables must start with an alphabet character. This is because programming languages have specific rules for naming variables, and starting with a number or a special symbol can cause syntax errors or confusion in the code.

Submit
26. A character variable can at a time score?

Explanation

A character variable can at a time store only one character. This is because a character variable is designed to hold a single character value. It cannot store multiple characters or a string of characters. Therefore, the correct answer is 1 character.

Submit
27. Compute the result of the following expression in ‘C’. A=3*4/5+10/5+8-1+7/8

Explanation

The expression A=3*4/5+10/5+8-1+7/8 can be simplified as follows:
- First, we perform the multiplication and division operations from left to right: 3*4/5 = 12/5
- Next, we perform the addition and subtraction operations from left to right: 12/5 + 10/5 + 8 - 1 + 7/8 = 2.4 + 2 + 8 - 1 + 0.875
- Finally, we add up all the values: 2.4 + 2 + 8 - 1 + 0.875 = 11.275
Since the result is a decimal number, we round it down to the nearest whole number, which is 11.
Therefore, the correct answer is 11.

Submit
28. Which of the following is a correct way of defining a symbolic constant pie in C

Explanation

The correct way of defining a symbolic constant pie in C is by using the #define directive followed by the constant name (pie) and its value (22/7). This creates a macro that replaces every occurrence of "pie" in the code with the value 22/7.

Submit
29. Which of the following is not correct

Explanation

The statement "while loop is executed at least once" is incorrect. A while loop is only executed if the condition is true. If the condition is initially false, the loop will not be executed at all.

Submit
30. Which of the following is not a storage class

Explanation

The storage class "define" does not exist in the C programming language. The other three options, external, automatic, and register, are all valid storage classes in C. The "define" option is most likely included in the question to confuse the reader, as it is a common keyword used in preprocessor directives, but it is not a storage class.

Submit
31. The amount of storage required for holding elements of the array depends on

Explanation

The amount of storage required for holding elements of the array depends on both the data type and the size. Different data types have different sizes in memory, so the storage needed will vary based on the data type used. Additionally, the size of the array, which determines the number of elements it can hold, also affects the amount of storage required. Therefore, both the data type and the size of the array are factors that determine the amount of storage needed.

Submit
32. What will be the output of the following program? #include<stdio.h> int main() { int a = 1, b = 2, c = 3; printf("The value of a is %d", ++a); func(); printf(" The value of a is %d", ++a); return 0; } void func() { int a = 10; return 0; }

Explanation

The output of the program will be "The value of a is 2 The value of a is 3". This is because the value of a is incremented by 1 using the pre-increment operator (++a) before the first printf statement. Then the function func() is called, but it does not affect the value of a. Finally, after the function call, the value of a is again incremented by 1 before the second printf statement.

Submit
33. The real constant in C can be expressed in which of the following forms?

Explanation

The real constant in C can be expressed in both fractional and exponential forms. This means that a real constant in C can be represented as a fraction or in scientific notation with an exponent. For example, a real constant can be written as 0.5 or as 5e-1. Both forms are valid ways to express a real constant in C.

Submit
34. Which of the following statements is false

Explanation

The initialization part of a for statement can have more than one initialization. In a for statement, the initialization part allows multiple variables to be initialized. This is done by separating the initializations with commas. Therefore, the statement "The initialization part of a for statement cannot have more than one initialization" is false.

Submit
35. Consider the segment If(1) printf(“yes”); else printf(“no”); what will be the output

Explanation

The output will be "yes" because the condition in the if statement (1) is true. Therefore, the code inside the if block will be executed, which is to print "yes" using the printf function.

Submit
36. The minimum number of times the for loop is executed is

Explanation

The for loop is a control structure that executes a block of code repeatedly until a certain condition is met. In this case, the minimum number of times the for loop is executed is 0. This means that the loop will not execute at all if the condition is not met initially. Therefore, the correct answer is 0.

Submit
37. If statement is a —————statement

Explanation

A two-way decision statement is a type of statement that allows the program to make a decision between two possible outcomes. It typically uses a conditional expression to evaluate a condition and then executes different blocks of code based on whether the condition is true or false. This type of statement is commonly used in programming to implement if-else constructs, where one block of code is executed if the condition is true and another block is executed if the condition is false.

Submit
38. What will be the output of the following program? #include<stdio.h> #define putchar(c) printf("%c",c) int  main() { char s='c'; putchar (s); return 0; }

Explanation

The program defines a macro called putchar which takes a character as an argument and prints it using the printf function. In the main function, a character variable s is assigned the value 'c'. Then, the putchar macro is called with the argument s, which is 'c'. As a result, the character 'c' is printed. Therefore, the output of the program will be c.

Submit
39. What will happen if you try to put so many values into an array during the initalization such that its size is  exceeded

Explanation

If you try to put too many values into an array during initialization and exceed its size, it can lead to a possible system malfunction. This is because the array is allocated a fixed amount of memory based on its size during initialization. When you try to store more values than the allocated memory can hold, it can cause memory corruption and potentially crash the system or cause unexpected behavior.

Submit
40. What will be the output of the following program? #include<stdio.h> int main() { char numbers[5][6] = {"Zero","One","Two","Three","Four"}; printf("%s is %c",&numbers[4][0],numbers[0][0]); return 0; }

Explanation

The program creates a 2-dimensional character array called "numbers" with 5 rows and 6 columns. Each row represents a word. In the printf statement, it prints the character at the first index of the 5th row of the "numbers" array, which is 'F', and the character at the first index of the 1st row of the "numbers" array, which is 'Z'. Therefore, the output will be "Four is Z".

Submit
41. If we don’t initialize a static array, what will be the elements set to:

Explanation

If we don't initialize a static array, the elements will be set to 0. This means that each element in the array will have a value of 0 by default.

Submit
42. What  is the output of the below program? #include<stdio.h> int main() { printf("%c", "abcdefgh"[6]); return 0; }

Explanation

The program is using array indexing to access the character at index 6 of the string "abcdefgh". Since array indexing starts at 0, the character at index 6 is 'g'. Therefore, the output of the program will be 'g'.

Submit
43. The statements that prints out the character set from A-Z is, where a is an integer variable

Explanation

The correct answer is "for(a='A' a". This statement initializes the variable "a" with the character 'A' and then loops while "a" is less than or equal to the character set's last character, which is 'Z'. Therefore, it will print out the character set from A to Z. The other statements either have syntax errors or do not cover the entire character set.

Submit
44. How many bytes will be allotted for the declaration int num[4] [3]

Explanation

The declaration "int num[4][3]" indicates a two-dimensional array with 4 rows and 3 columns. Since each element in the array is of type "int", which typically takes up 4 bytes of memory, the total memory allocated can be calculated by multiplying the number of rows by the number of columns by the size of each element. In this case, 4 rows multiplied by 3 columns multiplied by 4 bytes gives us a total of 24 bytes.

Submit
45. What is wrong with the following program main() { char m1[9]= “message1”; char m2[9]=“message2”; m2=m1; printf(“msg is %s”,m2); }

Explanation

The program is attempting to assign the value of m1 to m2, but arrays cannot be assigned to in this way. Arrays are not considered left values, meaning they cannot be assigned to like variables. This causes a compilation error in the program.

Submit
46. In switch statement

Explanation

The correct answer is that the default case, if used, can be placed anywhere in a switch statement. Unlike other cases, the default case does not require a specific position and can be placed anywhere within the switch statement. This allows for flexibility in the code structure and logic, as the default case can be positioned based on the specific requirements of the program.

Submit
47. The total memory required for an array

Explanation

The correct answer is "sizeof (datatype) * sizeof array". This is because the sizeof operator returns the size in bytes of the datatype, and multiplying it by the sizeof array gives the total memory required for the array.

Submit
48. Which one of the following is an example of storage class in C?

Explanation

The correct answer is "extern" because it is a storage class in the C programming language. The "extern" keyword is used to declare a variable that is defined in another file, allowing the variable to be accessed by multiple files in a program. This storage class is commonly used when creating global variables that need to be shared across multiple source files.

Submit
49. Main() { char name[5]; scanf(“%s”,name); printf(“%s”, name); }if Program is the given as input, what will be the o/p of the program;

Explanation

The program declares a character array named "name" with a size of 5. It then scans for input and stores it in the "name" array. Since the input is "Program", which is 7 characters long, it will only store the first 4 characters ("Prog") in the "name" array. Finally, it prints the contents of the "name" array, which is "Prog". Therefore, the output of the program will be "Prog".

Submit
50. What will be the output of the following program? #include<stdio.h> enum {TRUE, FALSE}; int main() { int i=1; do{ printf("%d\t",i); i++; if(i > 5) break; } while(TRUE); return 0; }

Explanation

The program uses a do-while loop to print the value of the variable i and increments it by 1 each time. It also includes a condition that if i becomes greater than 5, the loop will break. Since the condition of the loop is set to TRUE, the loop will continue indefinitely until it is manually broken. In this case, the loop will print the numbers 1, 2, 3, 4, and 5 before breaking out of the loop. Therefore, the output of the program will be "1 2 3 4 5".

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

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
  • Jun 22, 2014
    Quiz Created by
    Sunil Singhal
Cancel
  • All
    All (50)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the follwing is a string
The maximum number of dimension an array can have in C language is
C can be used on?
C programs are converted into the machine language with the help of?
How would you copy the name "Hello" to a character array (i.e. string)...
Array subscripts in ‘C’ always start at
Linux was developed mainly using C language. 
The value within the [] brackets in an array declaration specifies
What is the output of the following module ...
What is the result of the expression ( 10/3 )*3+5%3 ?
Consider the array definition ...
Identify the loop construct:
Give the output of the following program: ...
Output of the below program ...
The global variable can be declared
How many while statements are possible in do.... While loop?
Which of the following statements would read a single character from...
What is the output of the following program ...
The maximum value that an integer constant can have is?
The storage area for register variables
C language has been developed by?
Count=0; ...
Dynamic memory allocation in array results in
Printf (“\ “ well done\” ”); what will be the output of this...
A-C variable cannot start with?
A character variable can at a time score?
Compute the result of the following expression in ‘C’....
Which of the following is a correct way of defining a symbolic...
Which of the following is not correct
Which of the following is not a storage class
The amount of storage required for holding elements of the array...
What will be the output of the following program? ...
The real constant in C can be expressed in which of the following...
Which of the following statements is false
Consider the segment ...
The minimum number of times the for loop is executed is
If statement is a —————statement
What will be the output of the following program? ...
What will happen if you try to put so many values into an array during...
What will be the output of the following program? ...
If we don’t initialize a static array, what will be the elements set...
What  is the output of the below program? ...
The statements that prints out the character set from A-Z is, where a...
How many bytes will be allotted for the declaration int num[4] [3]
What is wrong with the following program ...
In switch statement
The total memory required for an array
Which one of the following is an example of storage class in C?
Main() ...
What will be the output of the following program? ...
Alert!

Advertisement