PGDCA Second Semester Exam 2019 13/09/2019

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.
Learn about Our Editorial Process
| By Ocaplb.2010
O
Ocaplb.2010
Community Contributor
Quizzes Created: 2 | Total Attempts: 260
Questions: 50 | Attempts: 122

SettingsSettingsSettings
Assessment Quizzes & Trivia

.


Questions and Answers
  • 1. 

    Identify the loop construct:

    • A.

      If-else

    • B.

      Goto

    • C.

      While

    • D.

      Switch-case

    Correct Answer
    C. While
    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.

    Rate this question:

  • 2. 

    Which of the following is not a storage class

    • A.

      External

    • B.

      Automatic

    • C.

      Register

    • D.

      Define

    Correct Answer
    D. Define
    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.

    Rate this question:

  • 3. 

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

    • A.

      # define pie = 22/7

    • B.

      #define pie 22/7

    • C.

      #define pie= 3.142

    • D.

      # Define pie 22/7

    Correct Answer
    B. #define pie 22/7
    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).

    Rate this question:

  • 4. 

    The minimum number of times the for loop is executed is

    • A.

      0

    • B.

      Cannot be predicted

    • C.

      1

    • D.

      2

    Correct Answer
    A. 0
    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.

    Rate this question:

  • 5. 

    In switch statement

    • A.

      More than one default allowesd

    • B.

      Default case, if used, should be the last case

    • C.

      Default case, if used, can be placed anywhere

    • D.

      Default case must be present

    Correct Answer
    C. Default case, if used, can be placed anywhere
    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.

    Rate this question:

  • 6. 

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

    • A.

      2

    • B.

      3

    • C.

      Any number

    • D.

      1

    Correct Answer
    C. Any number
    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.

    Rate this question:

  • 7. 

    The storage area for register variables

    • A.

      Cache

    • B.

      Memory

    • C.

      Processor registers

    • D.

      Virtual memory

    Correct Answer
    C. Processor registers
    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.

    Rate this question:

  • 8. 

    Which of the following statements is false

    • A.

      The initialization and increment parts of a for statement can be empty

    • B.

      The body of do-while statement can be empty

    • C.

      The expression in the condition part of a for statement can be empty

    • D.

      The initialization part of a for statement cannot have more than one initialization

    Correct Answer
    D. The initialization part of a for statement cannot have more than one initialization
    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.

    Rate this question:

  • 9. 

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

    • A.

      No

    • B.

      Unpredictable

    • C.

      Yes

    • D.

      Error

    Correct Answer
    C. Yes
    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.

    Rate this question:

  • 10. 

    The global variable can be declared

    • A.

      After main

    • B.

      After block

    • C.

      Before main

    • D.

      Within block

    Correct Answer
    C. Before main
    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.

    Rate this question:

  • 11. 

    Which of the following is not correct

    • A.

      While loop is executed atleast once

    • B.

      Do . while loop is executed at least once

    • C.

      While loop is executed only if the condition is true

    • D.

      Dowhile loop is ececuted only if the condition is true

    Correct Answer
    A. While loop is executed atleast once
    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.

    Rate this question:

  • 12. 

    printf (“\ “ well done\” ”); what will be the output of this statement

    • A.

      \“well done \”

    • B.

      Well done

    • C.

      “ well done”

    • D.

      \ well done \

    Correct Answer
    C. “ well done”
    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.

    Rate this question:

  • 13. 

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

    • A.

      0

    • B.

      Run-time error

    • C.

      Undefined

    • D.

      Compilation error

    Correct Answer
    A. 0
    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.

    Rate this question:

  • 14. 

    The number of elements in array declaration

    • A.

      Dynamically identifies based on largest index used in program

    • B.

      Does not require to be specified

    • C.

      Assume default size as ‘0’

    • D.

      Requires to be specified

    Correct Answer
    D. Requires to be specified
    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.

    Rate this question:

  • 15. 

    In C every variable has

    • A.

      A type and size

    • B.

      A type, name, value and size

    • C.

      A name and type

    • D.

      A size and value

    Correct Answer
    B. A type, name, value and size
    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.

    Rate this question:

  • 16. 

    All the elements in the array must be

    • A.

      Defined

    • B.

      Neither initialized nor defined

    • C.

      Initialized and defined

    • D.

      Initialized

    Correct Answer
    A. Defined
    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.

    Rate this question:

  • 17. 

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

    • A.

      6 bytes

    • B.

      24 bytes

    • C.

      12 bytes

    • D.

      48 bytes

    Correct Answer
    B. 24 bytes
    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.

    Rate this question:

  • 18. 

    If statement is a —————statement

    • A.

      Loop construct

    • B.

      Two way decision

    • C.

      Multiway decision

    • D.

      One-way decision

    Correct Answer
    D. One-way decision
    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.

    Rate this question:

  • 19. 

    The total memory required for an array

    • A.

      Sizeof (datatype) * 2

    • B.

      Size of (datatype) * size of used array elements

    • C.

      Sizeof (datatype) * sizeof array

    • D.

      Size of (array) * datatype

    Correct Answer
    C. Sizeof (datatype) * sizeof 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.

    Rate this question:

  • 20. 

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

    • A.

      None of the element are initialized to zero

    • B.

      Only first row elements are initialized to zero

    • C.

      Only last row elements are initialized to zero

    • D.

      All the array elements are initialized to zero

    Correct Answer
    D. All the array elements are initialized to zero
    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.

    Rate this question:

  • 21. 

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

    • A.

      For(a=‘A’; a

    • B.

      For(a=‘A’; a

    • C.

      For(a=‘a’; a

    • D.

      For(a=’A’ a

    Correct Answer
    D. For(a=’A’ a
    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'.

    Rate this question:

  • 22. 

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

    • A.

      Data type

    • B.

      Datatype and size

    • C.

      Run-time requirement

    • D.

      Size

    Correct Answer
    B. Datatype and size
    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.

    Rate this question:

  • 23. 

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

    • A.

      Character constant

    • B.

      A floating point number

    • C.

      0

    • D.

      An undetermined value

    Correct Answer
    D. An undetermined value
    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.

    Rate this question:

  • 24. 

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

    • A.

      Char array cannot be printed directly using printf

    • B.

      Array is not a left value and so cannot be assigned to

    • C.

      Program compiles without error, but prints an unpredictable value

    • D.

      Array cannot be initialized as above

    Correct Answer
    D. Array cannot be initialized as above
    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.

    Rate this question:

  • 25. 

    Array subscripts in ‘C’ always start at

    • A.

      0

    • B.

      Compiler dependent

    • C.

      1

    • D.

      -1

    Correct Answer
    A. 0
    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.

    Rate this question:

  • 26. 

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

    • A.

      4

    • B.

      5

    • C.

      Compiler dependent

    • D.

      3

    Correct Answer
    C. Compiler dependent
    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.

    Rate this question:

  • 27. 

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

    • A.

      10

    • B.

      11

    • C.

      8

    • D.

      1

    Correct Answer
    B. 11
    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.

    Rate this question:

  • 28. 

    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); }

    • A.

      1 3 6 10 15 21 28 32 45 45

    • B.

      55

    • C.

      45

    • D.

      0

    Correct Answer
    C. 45
    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.

    Rate this question:

  • 29. 

    consider the array definition int num [10] = { 3 ,3 ,3 }; pick the correct answers

    • A.

      This is syntactically wrong

    • B.

      The value of num[8] is 3

    • C.

      This is invalid if it comes within a function

    • D.

      The value of num[2] is 3

    Correct Answer
    D. The value of num[2] is 3
    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.

    Rate this question:

  • 30. 

    Which of the follwing is a string

    • A.

      ‘abcd’

    • B.

      “abcd”

    • C.

      Abcd

    • D.

      ‘abcd”

    Correct Answer
    B. “abcd”
    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.

    Rate this question:

  • 31. 

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

    • A.

      Print the value of I as 1

    • B.

      Warning for no return type for main ( )

    • C.

      Infinite loop

    • D.

      Prints the value of I as11111

    Correct Answer
    C. Infinite loop
    Explanation
    The given program will result in an infinite loop because the condition in the while loop (I < 5) is always true and there is no statement inside the loop to change the value of I. Therefore, the program will keep printing the value of I (which is 1) indefinitely.

    Rate this question:

  • 32. 

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

    • A.

      Strcpy( str, “Hello” );

    • B.

      Strcat(str,“Hello”);

    • C.

      Printf( str, “Hello” );

    • D.

      Str = “Hello”;

    Correct Answer
    A. Strcpy( str, “Hello” );
    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.

    Rate this question:

  • 33. 

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

    • A.

      6

    • B.

      3

    • C.

      4

    • D.

      5

    Correct Answer
    A. 6
    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.

    Rate this question:

  • 34. 

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

    • A.

      Error message from the compiler

    • B.

      Possible system malfunction

    • C.

      Last element data may be overwritten

    • D.

      Nothing

    Correct Answer
    B. Possible system malfunction
    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.

    Rate this question:

  • 35. 

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

    • A.

      11

    • B.

      10

    • C.

      12

    • D.

      9

    Correct Answer
    A. 11
    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.

    Rate this question:

  • 36. 

    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;

    • A.

      Ch = getch( );

    • B.

      Printf( “%c”, ch );

    • C.

      While(!kbhit)

    • D.

      Getkeyb ( ch );

    Correct Answer
    A. Ch = getch( );
    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'.

    Rate this question:

  • 37. 

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

    • A.

      28

    • B.

      10

    • C.

      15

    • D.

      21

    Correct Answer
    C. 15
    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.

    Rate this question:

  • 38. 

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

    • A.

      Value of the array element

    • B.

      Subscript value

    • C.

      Address value

    • D.

      Size of an array

    Correct Answer
    D. Size of an array
    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.

    Rate this question:

  • 39. 

    Dynamic memory allocation in array results in

    • A.

      Allocation of memory at debugging time

    • B.

      Allocation of memory at file saving time

    • C.

      Allocation of memory at compile time

    • D.

      Allocation of memory at runtime

    Correct Answer
    D. Allocation of memory at runtime
    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.

    Rate this question:

  • 40. 

    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;

    • A.

      Progr

    • B.

      Prog

    • C.

      Program

    • D.

      Runtime error

    Correct Answer
    B. Prog
    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".

    Rate this question:

  • 41. 

    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; }

    • A.

      Four is Z

    • B.

      Three is Z

    • C.

      Compiler error

    • D.

      Two is Z

    Correct Answer
    A. Four is Z
    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".

    Rate this question:

  • 42. 

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

    • A.

      Int and float

    • B.

      Extern

    • C.

      Both 1 & 2

    • D.

      Neither 1 nor 2

    Correct Answer
    B. Extern
    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.

    Rate this question:

  • 43. 

    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; }

    • A.

      The value of a is 2 The value of a is 2

    • B.

      The value of a is 2 The value of a is 3

    • C.

      The value of a is 1 The value of a is 10

    • D.

      Compiler error

    Correct Answer
    B. The value of a is 2 The value of a is 3
    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.

    Rate this question:

  • 44. 

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

    • A.

      G

    • B.

      E

    • C.

      F

    • D.

      Compiler Error

    Correct Answer
    A. G
    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'.

    Rate this question:

  • 45. 

    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; }

    • A.

      99

    • B.

      Compiler Error

    • C.

      Runtime Error

    • D.

      C

    Correct Answer
    D. C
    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'.

    Rate this question:

  • 46. 

    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; }

    • A.

      1 2 3 4 5

    • B.

      It prints an infinite loop of numbers

    • C.

      1 2 3 4

    • D.

      1

    Correct Answer
    D. 1
    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.

    Rate this question:

  • 47. 

    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; }

    • A.

      Successful

    • B.

      Compiler error

    • C.

      Compiler warning

    • D.

      None of these

    Correct Answer
    B. Compiler error
    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.

    Rate this question:

  • 48. 

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

    • A.

      Mutable

    • B.

      Volatile

    • C.

      Static

    • D.

      None of these

    Correct Answer
    B. Volatile
    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.

    Rate this question:

  • 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; }

    • A.

      It will print "you are in fun" endlessly

    • B.

      Infinite loop

    • C.

      It is an example of tree recursion

    • D.

      Stack overflow

    Correct Answer
    D. Stack overflow
    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.

    Rate this question:

  • 50. 

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

    • A.

      Main(int argc, char argv)

    • B.

      Main(char argv[ ], int *argc)

    • C.

      Main(char* argv[ ],int argc)

    • D.

      Main(int argc,char* argv[ ])

    Correct Answer
    D. Main(int argc,char* argv[ ])
    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.

    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 17, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 06, 2019
    Quiz Created by
    Ocaplb.2010
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.