PGDCA Second Semester Exam 2019 13/09/2019

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 Ocaplb.2010
O
Ocaplb.2010
Community Contributor
Quizzes Created: 2 | Total Attempts: 268
| Attempts: 129 | Questions: 50
Please wait...
Question 1 / 50
0 %
0/100
Score 0/100
1. What is the result of the expression ( 10/3 )*3+5%3 ?

Explanation

The expression (10/3) evaluates to 3.33. The expression 3+5%3 evaluates to 4 because the remainder of 5 divided by 3 is 2, and then 3 is added to 2. Therefore, the result of the entire expression is 3 + 4 which equals 7.

Submit
Please wait...
About This Quiz
PGDCA Second Semester Exam 2019 13/09/2019 - Quiz

This quiz, titled 'PGDCA Second Semester Exam 2019 13\/09\/2019', assesses knowledge in C programming, focusing on control structures such as loops and conditional statements. It evaluates understanding of... see moreloop constructs, storage classes, symbolic constants, and the functionality of switch and do. . . While statements. see less

2. Which of the follwing is a string

Explanation

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

Submit
3. 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 will result in an infinite loop because the condition in the while loop (I

Submit
4. 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 that 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 s as the argument, which will print the character 'c'. Therefore, the output of the program will be 'c'.

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

Explanation

The expression given can be evaluated using the order of operations in mathematics. First, we perform the multiplication and division from left to right. 3 multiplied by 4 is 12, and when divided by 5, the result is 2.4. Similarly, 10 divided by 5 is 2.0. Then, we perform the addition and subtraction from left to right. Adding 2.4, 2.0, 8, -1, and 0.875 (7 divided by 8) gives us a final result of 11.

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

Explanation

In a do...while loop, the condition is checked after the loop is executed. This means that the loop will always execute at least once. After each iteration, the condition is checked, and if it is true, the loop will continue. Therefore, there can be any number of while statements in a do...while loop, depending on the condition.

Submit
7. 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, float, or character. The name is the identifier used to refer to the variable in the program. The value is the actual data stored in the variable. The size represents the amount of memory allocated to store the variable, which depends on its type. Having a type, name, value, and size for each variable is essential for proper memory allocation and data manipulation in the C programming language.

Submit
8. 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 the variable "I" is initialized to 0. Inside the do-while loop, the value of "I" is added to "sum" and then "I" is incremented by 1. This process continues until "I" becomes greater than 5. Therefore, the final value of "sum" is 15, which is the correct answer.

Submit
9. 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. It starts with i=1 and increments it by 1 in each iteration. The condition for the loop to continue is TRUE, which is equivalent to the value 1. However, there is a break statement inside the loop that will be executed when i becomes greater than 5. Therefore, the loop will only iterate 5 times, printing the values 1, 2, 3, 4, and 5.

Submit
10. 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 defined outside of any function, including the main function, and can be accessed and used by any function within the program. Declaring a variable before the main function allows it to have a global scope, meaning it can be accessed from anywhere in the program. This is useful when a variable needs to be shared and used by multiple functions.

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

Explanation

The given code snippet is using the printf function to print the string "\ " well done\" ". However, the backslash character "\" is an escape character in C programming, so it is used to escape the following character. In this case, the backslash before the double quotes is escaping the double quotes, so the output will be " well done" with a space before the "well done" string.

Submit
12. 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 exceeding the array's size can cause memory corruption, leading to unpredictable behavior in the system. It can result in memory leaks, crashes, or other system errors, making the system malfunction.

Submit
13. 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
14. Dynamic memory allocation in array results in

Explanation

Dynamic memory allocation in array allows for the allocation of memory at runtime. This means that the memory is allocated during the execution of the program, allowing for flexibility in the amount of memory needed. Unlike static memory allocation, which occurs at compile time, dynamic memory allocation allows for the allocation and deallocation of memory as needed during program execution. This is particularly useful when the size of the array is not known beforehand or may change during runtime.

Submit
15. What will be the output of the following program ? #include<stdio.h> int main(){ typedef struct{char ch;}st; st s1 = {'c'}; st s2 = s1; if(s1 == s2) printf("Successful"); return 0; }

Explanation

The program will result in a compiler error. This is because the comparison operator (==) cannot be used to compare two struct variables. Struct variables cannot be directly compared using the equality operator.

Submit
16. The storage area for register variables

Explanation

Processor registers are small, high-speed storage areas located within the CPU. They are used to store data that is frequently accessed by the processor, such as variables and intermediate results of calculations. Register variables are stored directly in these registers, providing fast access and improving the overall performance of the program. This is why the storage area for register variables is referred to as processor registers.

Submit
17. 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 provided within double curly brackets. In this case, the elements are initialized to zero. Since no specific values are assigned to any element, all the elements in the array are initialized to zero.

Submit
18. 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 a string input and store it in the "name" array. Since the array can only hold 5 characters, any input longer than that will result in a buffer overflow. In this case, the input "Program" has 7 characters, so only the first 4 characters "Prog" will be stored in the array. Finally, the program uses the printf function to print the contents of the "name" array, which will output "Prog".

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

Explanation

The correct answer is "extern". In C programming, "extern" is a storage class that is used to declare a variable or function that is defined in another source file. It is used to provide a reference to a global variable or function that is defined in a different file. The "int" and "float" are data types in C, not storage classes. Therefore, option 2, "extern", is the correct example of a storage class in C.

Submit
20. 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 variable "a" is incremented twice using the pre-increment operator (++a) before the first printf statement and before the second printf statement. The function func() does not affect the value of "a" as it has its own local variable with the same name.

Submit
21. 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 us to initialize multiple variables or perform multiple initialization operations using commas. Therefore, it is possible to have more than one initialization in the initialization part of a for statement.

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

Explanation

The condition in the if statement is 1, which is considered as true in C programming. Therefore, the code inside the if block will be executed, resulting in the output "yes" being printed.

Submit
23. 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. Each element of this array is an integer, which typically requires 4 bytes of memory. Since there are a total of 4*3=12 elements in the array, the total memory allotted will be 12*4=48 bytes. Therefore, the correct answer is 24 bytes.

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

Explanation

In 'C', 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 the subscript 1, and so on. This convention is followed in 'C' programming language and is important to keep in mind while working with arrays to avoid any indexing errors.

Submit
25. 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 is a loop that 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, the count variable is incremented by 1. Since there are 6 even numbers between 0 and 10 (0, 2, 4, 6, 8, 10), the correct value for count is 6.

Submit
26. 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 declares a 2D array of characters called "numbers" with 5 rows and 6 columns. It initializes the array with the strings "Zero", "One", "Two", "Three", and "Four".

In the printf statement, it prints the first character of the string at index 4 of the second dimension of the "numbers" array (which is the string "Four"), followed by the first character of the string at index 0 of the first dimension of the "numbers" array (which is the string "Zero").

Therefore, the output of the program will be "Four is Z".

Submit
27. 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 6th element of the string "abcdefgh", which is 'g'. The printf function then prints this character. Therefore, the output of the program is 'g'.

Submit
28. What is the keyword used to turn off the compiler optimization of a variable?

Explanation

The keyword "volatile" is used to turn off the compiler optimization of a variable. When a variable is declared as volatile, it tells the compiler that the value of the variable can be changed unexpectedly by external factors, such as another thread or hardware. This prevents the compiler from optimizing the variable by caching its value, ensuring that the variable is always read from memory and not from a cached value. This is useful in scenarios where the variable's value can be modified outside of the program's control.

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

Explanation

This statement `for(a=’A’ a` is the correct answer because it initializes the variable `a` with the character 'A' and loops through the character set from A to Z. The loop will continue as long as `a` is less than or equal to 'Z'.

Submit
30. 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 size 10, but only provides 3 values. In this case, the remaining elements of the array will be automatically initialized to 0. Therefore, the value of num[2] will be 3, as it is the third element of the array.

Submit
31. In switch statement

Explanation

In a switch statement, if a default case is used, it can be placed anywhere within the switch statement. This means that it doesn't necessarily have to be the last case. The default case is executed when none of the other cases match the value being switched on. So, if the default case is placed before other cases, it will be executed if none of those cases match.

Submit
32. The number of elements in array declaration

Explanation

In array declaration, the number of elements usually needs to be specified. This is because the compiler needs to allocate memory for the array based on the specified size. If the size is not specified, the compiler will not know how much memory to allocate, leading to potential errors or unexpected behavior. Therefore, it is necessary to specify the number of elements in the array declaration.

Submit
33. 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 initializes an integer variable 'a' and sets it to 0. It also initializes an integer variable 'b' and sets it to 0. It then creates an integer array 'c' with 10 elements and assigns the values 1, 2, 3, 4, 5, 6, 7, 8, 9, and 0 to the elements respectively.

Next, a for loop is used to iterate through the array 'c' and add each element to 'b'. After the loop, the value of 'b' is printed.

Since 'b' is initialized to 0 and each element of 'c' is added to it in the loop, the final value of 'b' is the sum of all the elements in 'c', which is 45.

Submit
34. Identify the loop construct:

Explanation

The loop construct identified in this question is "while". The "while" loop is used to repeatedly execute a block of code as long as a specified condition is true. It checks the condition before executing the code, and if the condition is true, it continues to execute the code block. Once the condition becomes false, the loop terminates and the program continues with the next line of code after the loop.

Submit
35. 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 condition in the for loop is initially false, the loop will not execute at all.

Submit
36. All the elements in the array must be

Explanation

The correct answer is "defined" because in order to use elements in an array, they must be defined, meaning that they have been declared and given a value. Initialization is not necessary, as the elements can be assigned values later on. However, they must be defined before they can be used in any operations or calculations.

Submit
37. The total memory required for an array

Explanation

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

Submit
38. 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" preprocessor directive followed by the name of the constant "pie" and its value "22/7". This creates a symbolic constant called "pie" with the value of the mathematical constant pi (approximately 3.142).

Submit
39. Which of the following is not correct

Explanation

The explanation for the given correct answer is that a while loop is not executed at least once. This is because the while loop checks the condition before executing the code inside the loop. If the condition is initially false, the code inside the loop will not be executed at all.

Submit
40. 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 is because strcpy() function is used to copy the string "Hello" into the character array str. It takes two arguments - the destination array (str) and the source string ("Hello"). It copies the source string into the destination array, overwriting any previous content in the array.

Submit
41. Which one of the following is the correct way of declaring main() function when it receives command line arguments?

Explanation

The correct way of declaring the main() function when it receives command line arguments is "main(int argc,char* argv[ ])". In this declaration, "argc" represents the number of command line arguments passed to the program, and "argv" is an array of strings containing the actual arguments.

Submit
42. 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 initialize it. In C, static variables are automatically initialized to 0. Therefore, when the program prints the value of 'y', it will output 0.

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

Explanation

The maximum number of dimensions an array can have in the C language is dependent on the compiler being used. Different compilers may have different limitations on the number of dimensions allowed for an array. Therefore, the maximum number of dimensions is not fixed and can vary based on the compiler being used.

Submit
44. 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 determines the number of elements that the array can hold.

Submit
45. If statement is a —————statement

Explanation

A one-way decision statement is a type of programming statement that allows for the execution of a block of code only if a certain condition is true. It does not provide any alternative paths or options for the code execution. In other words, it allows for a single path of execution based on the condition being true or false. This is different from other types of decision statements such as two-way or multiway decision statements, which provide multiple paths or options for code execution based on different conditions.

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

Explanation

The storage classes in C programming language define the scope and lifetime of variables. The "define" option mentioned in the question is not a storage class. In C, "define" is used to create a macro or a constant value using the preprocessor directive #define. It does not deal with the scope or lifetime of variables like the storage classes do.

Submit
47. 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 given program is trying to assign the value of one character array (m1) to another character array (m2) using the assignment operator (=). However, in C, arrays cannot be assigned directly. Instead, each element of the array needs to be copied individually. Therefore, the program is incorrect because it is trying to assign the entire array m1 to m2, which is not allowed.

Submit
48. 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 have different sizes in memory, and the size of the array also affects the total storage required. For example, an array of integers will require more storage than an array of characters because integers typically have a larger size in memory. Similarly, a larger array will require more storage than a smaller array, regardless of the data type. Therefore, both the data type and size of the array are important factors in determining the amount of storage required.

Submit
49. What will be the output of the following program? #include<stdio.h> int main() { fun(); } fun() { printf("you are in fun"); main(); return 0; }

Explanation

The program will go into an infinite loop and print "you are in fun" endlessly. This is because the function fun() is calling the main() function recursively, creating an infinite loop. Eventually, the recursive calls will cause a stack overflow error, leading to the program crashing.

Submit
50. 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 an undetermined value. This means that the values of the elements in the array will be unpredictable and could be any random value that happens to be stored in memory at that time. Therefore, it is important to always initialize static arrays to avoid accessing and using undefined values.

Submit
View My Results

Quiz Review Timeline (Updated): Apr 25, 2024 +

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

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

Advertisement