C Programming Exam Quiz!

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 Gaurabhkumar750
G
Gaurabhkumar750
Community Contributor
Quizzes Created: 1 | Total Attempts: 787
| Attempts: 787 | Questions: 40
Please wait...
Question 1 / 40
0 %
0/100
Score 0/100
1. In C every variable has:

Explanation

In C, every variable has a type, name, value, and size. The type determines the kind of data that the variable can hold, such as integer, character, or floating-point. The name is used to identify the variable and access its value. The value is the actual data stored in the variable. The size represents the amount of memory allocated for the variable, which depends on its type.

Submit
Please wait...
About This Quiz
C Programming Exam Quiz! - Quiz

Do you understand C Programming? It is often a wellspring of confusion for those who are not as advanced with computers. The focus here is identifying a loop construct, storage class, what is in a switch statement, and when the global variable can be declared. You must know a fai... see moreamount of mathematics to understand C Programming. If you are a computer major, you will not be disappointed with this awesome quiz. see less

Personalize your quiz and earn a certificate with your name on it!
2. Array subscripts in 'C' always start at:

Explanation

In the C programming language, array subscripts always start at 0. This means that the first element in an array is accessed using the subscript 0, the second element with subscript 1, and so on. This convention is followed in C and many other programming languages, and it is important to keep in mind when working with arrays to avoid off-by-one errors.

Submit
3. Identify the loop construct:

Explanation

The correct answer is "while" because it is a loop construct that allows a block of code to be repeatedly executed as long as a specified condition is true. The "while" loop first checks the condition, and if it is true, the code inside the loop is executed. This process continues until the condition becomes false, at which point the loop is exited.

Submit
4. 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.

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

Explanation

A do...while loop is a type of loop where the code block is executed at least once, and then the condition is checked. If the condition is true, the code block is executed again. This loop will continue until the condition becomes false. Therefore, any number of while statements are possible in a do...while loop, as long as the condition is true.

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

Explanation

The expression (10/3) evaluates to 3.3333, and when multiplied by 3, it becomes 9.9999. The expression 5%3 evaluates to 2, as it gives the remainder when 5 is divided by 3. Adding these two results together, we get 9.9999 + 2 = 11. Therefore, the result of the expression is 11.

Submit
7. The maximum number of dimension an array can have in C language is:

Explanation

In C language, the maximum number of dimensions an array can have is compiler dependent. This means that the maximum number of dimensions allowed for an array can vary depending on the compiler being used. Different compilers may have different limits on the number of dimensions allowed for an array. Therefore, the maximum number of dimensions an array can have in C language cannot be determined universally and is determined by the specific compiler being used.

Submit
8. Which of the following is not a storage class?

Explanation

The storage class "define" is not a valid storage class in programming languages. The options "external," "automatic," and "register" are all valid storage classes that define how variables are stored and accessed in memory. However, "define" is not a recognized storage class and does not have any specific meaning in this context.

Submit
9. 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 program contains a while loop that will continue to execute as long as the condition "I

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

Explanation

This is the correct way of defining a symbolic constant pie in C because it uses the correct syntax for the #define directive, which is followed by the name of the constant (pie in this case) and its corresponding value (22/7). The value is not assigned using the = symbol, but rather by leaving a space between the constant name and its value.

Submit
11. Consider the segment If(1) printf("yes"); else printf("no"); what will be the output

Explanation

The given segment is an if-else statement. If the condition (1) is true, then the code inside the if block will execute, which is to print "yes". Since the condition is 1, which is considered true in C programming, the output will be "yes".

Submit
12. Printf ("\ " well done\" "); what will be the output of this statement?

Explanation

The given statement will output " well done" (with a space before and after). This is because the printf function is used to print the string " well done" (including the space characters) to the console. The backslashes before and after the double quotes are escape characters, which are used to include special characters within the string. In this case, the backslashes are used to include the double quotes within the string.

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

Explanation

The program declares a static integer variable "y" inside the main function. Since static variables are initialized to zero by default, the value of "y" is 0. The program then prints the value of "y" using the printf function. Therefore, the output of the program is 0.

Submit
14. 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 given code initializes a variable count to 0. Then, it enters a for loop where it iterates from 0 to 10. Inside the loop, it checks if the current value of I is divisible by 2 (i.e., even). If it is, 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) between 0 and 10, the correct value for count is 6.

Submit
15. 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 code initializes the variables sum and I to 0. It then enters a do-while loop where it adds the value of I to the sum and increments I by 1. This process continues until I becomes greater than 5. After the loop ends, the value of sum is printed using the printf statement. Since the loop iterates 5 times and adds the values of I (1+2+3+4+5), the output will be 15.

Submit
16. 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 the data type and size. Different data types require different amounts of memory to store their values, and the size of the array determines how many elements can be stored. Therefore, both the data type and size of the array are factors that determine the amount of storage required.

Submit
17. Which of the follwing is a string?

Explanation

The correct answer is "abcd" because it is enclosed within double quotation marks, which is the standard way of representing a string in many programming languages. The other options either do not have any quotation marks or have mismatched quotation marks, making them invalid representations of a string.

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

Explanation

The declaration int num[4][3] creates a 2-dimensional array with 4 rows and 3 columns. Since an int data type typically requires 4 bytes of memory, each element in the array will take up 4 bytes. Therefore, the total memory allotted for the array will be 4 bytes * 4 rows * 3 columns, which equals 24 bytes.

Submit
19. 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();` because the `getch()` function reads a single character from the keyboard and returns it, which is then assigned to the character variable `ch`. This statement ensures that the character from the keyboard is stored in the variable `ch`.

Submit
20. 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 program execution, specifically at runtime. This means that the memory for the array is allocated dynamically based on the program's needs, allowing for flexibility in the size of the array. Unlike static memory allocation, which occurs at compile time and has a fixed size, dynamic memory allocation allows for the creation of arrays whose size can be determined and modified during program execution.

Submit
21. 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 will copy the string "Hello" to the character array "str". The other options are incorrect. strcat() is used to concatenate two strings, printf() is used to print a formatted string, and str = "Hello" is invalid syntax as you cannot assign a string directly to a character array.

Submit
22. The global variable can be declared:

Explanation

Global variables are variables that can be accessed and used throughout the entire program. They are typically declared before the main function because they need to be accessible to all other functions and blocks within the program. Declaring the global variable before main ensures that it is available and can be used by any function or block within the program.

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

Explanation

In the given program, the variable "m2" is declared as an array of characters. However, arrays are not assignable in C, meaning that we cannot directly assign one array to another. This is because arrays decay into pointers, and pointers cannot be assigned to. Therefore, the line "m2=m1;" is incorrect and will result in a compilation error.

Submit
24. The storage area for register variables.

Explanation

Processor registers are a small set of high-speed memory locations within the processor itself. They are used to store data that is frequently accessed by the processor, such as variables and intermediate results during calculations. Register variables are variables that are stored in processor registers instead of main memory. Storing variables in registers can improve performance because accessing data from registers is much faster than accessing data from memory. Therefore, processor registers are the most suitable storage area for register variables.

Submit
25. 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 and can include multiple expressions separated by commas. Therefore, the statement "The initialization part of a for statement cannot have more than one initialization" is false.

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

Explanation

The given array definition initializes an array named "num" with a size of 10 and assigns the values 3, 3, and 3 to the first three elements of the array. Since arrays in most programming languages are zero-indexed, the element at index 2 (num[2]) will have a value of 3.

Submit
27. 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. This value indicates the number of elements that can be stored in the array. It determines the amount of memory allocated for the array and helps in accessing the elements of the array using their respective indices.

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

Explanation

The minimum number of times the for loop is executed is 0 because if the loop's condition is not initially satisfied, the loop will not execute at all.

Submit
29. 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 given program initializes an array 'c' with 10 elements and assigns values from 1 to 10. It then uses a for loop to iterate through each element of the array and adds it to the variable 'b'. Finally, it prints the value of 'b', which is 45. Therefore, the output of the program is 45.

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

Explanation

The given expression is evaluated according to the order of operations in C. First, the multiplication and division operations are performed from left to right. So, 3 multiplied by 4 is 12, and 12 divided by 5 is 2.4. Next, the addition and subtraction operations are performed from left to right. So, 2.4 plus 2 is 4.4, and 4.4 minus 1 is 3.4. Finally, the division operation is performed, so 7 divided by 8 is 0.875. Adding 0.875 to 3.4 gives the final result of 4.275, which is rounded down to 4. Therefore, the correct answer is 11.

Submit
31. Which of the following is not correct?

Explanation

The statement "while loop is executed at least once" is not correct. In a while loop, the condition is checked before the loop body is executed. If the condition is false initially, the loop body will not be executed at all. Therefore, it is possible for a while loop to not be executed at least once.

Submit
32. The statement 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 is because 'A' is the ASCII value of the character 'A', and by incrementing the variable 'a' in each iteration of the loop, it will print out the character set from A-Z.

Submit
33. The number of elements in array declaration:

Explanation

The correct answer is "requires to be specified". In array declaration, the number of elements needs to be specified so that the compiler can allocate the appropriate amount of memory for the array. If the number of elements is not specified, the compiler will not know how much memory to allocate, resulting in a compilation error.

Submit
34. All the elements in the array must be:

Explanation

The correct answer is "defined" because in order for an element to be used in an array, it must be defined, meaning that it has been declared and given a specific type. Initialization is not necessary for an element to be considered defined in an array.

Submit
35. The total memory required for an array:

Explanation

The correct answer is sizeof (datatype) * sizeof array. This is because the total memory required for an array is calculated by multiplying the size of each element (datatype) by the total number of elements in the array (sizeof array).

Submit
36. If statement is a —————statement.

Explanation

A two-way decision statement is a type of statement that allows the program to make a choice between two possible paths based on a condition. It typically uses the keywords "if" and "else" to specify the conditions and the corresponding actions to be taken. This type of statement is commonly used when there are two alternative courses of action depending on the evaluation of a condition.

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

Explanation

If you try to put so many values into an array during initialization that exceeds its size, it can lead to a possible system malfunction. This is because the array is allocated a fixed amount of memory during initialization, and if you try to store more values than the allocated memory can hold, it can cause memory corruption and potentially crash the system.

Submit
38. In switch statement:

Explanation

In a switch statement, the default case is optional and can be placed anywhere within the switch block. It does not have to be the last case. The default case is executed when none of the other cases match the value being evaluated. It provides a fallback option for handling unexpected or unhandled values. However, it is good practice to place the default case at the end of the switch block to make the code more readable and to follow common conventions.

Submit
39. 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 uses the scanf function to read input from the user and store it in the "name" array. However, since the size of the array is only 5, it can only store up to 4 characters plus the null terminator. Therefore, when the input "Program" is given, only the first 4 characters "Prog" will be stored in the array. Finally, the printf function is used to print the contents of the "name" array, which will output "Prog".

Submit
40. Int table [2][3] ={{0}, {0}} in this statement.

Explanation

The given statement initializes a 2-dimensional array called "table" with 2 rows and 3 columns. The initialization values are given as {{0}, {0}}, which means that the first row elements are explicitly initialized to zero. However, since the second row is not specified, it is assumed to be initialized to zero as well. Therefore, all the array elements are initialized to zero.

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

Advertisement