Compile And Execute C Language Coding Quiz

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 Sscet
S
Sscet
Community Contributor
Quizzes Created: 1 | Total Attempts: 159
Questions: 25 | Attempts: 159

SettingsSettingsSettings
Compile And Execute C Language Coding Quiz - Quiz

Let's start this quiz it will give you the different functions of c language. Find out now how much do you know about it!


Questions and Answers
  • 1. 

    What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){   int array[3]={5};   int i;   for(i=0;i<=2;i++)     printf("%d ",array[i]);   return 0; }

    • A.

      5 garbage garbage

    • B.

      5 0 0

    • C.

      5 null null

    • D.

      Compiler error

    • E.

      None of above

    Correct Answer
    B. 5 0 0
    Explanation
    The code initializes an array named "array" with three elements. However, only the first element is given a value of 5, while the rest of the elements are not explicitly initialized. In C, when an array is not fully initialized, the remaining elements are automatically assigned a default value of 0. Therefore, when the code is executed, it will print "5 0 0".

    Rate this question:

  • 2. 

    What will be output if you will compile and execute the following c code? #include<stdio.h> void call(int,int,int); int main(){   int a=10;   call(a,a++,++a);   return 0; } void call(int x,int y,int z){   printf("%d %d %d",x,y,z); }

    • A.

      10 10 12

    • B.

      12 11 11

    • C.

      12 12 12

    • D.

      10 11 12

    • E.

      Compiler error

    Correct Answer
    B. 12 11 11
    Explanation
    The output of the code will be "12 11 11". In the main function, the call to the function "call" passes the values of variables "a", "a++", and "++a" as arguments. The value of "a" is initially 10. However, the order in which the arguments are evaluated is not defined in C. In this case, it seems that the arguments are evaluated from right to left. So, the value of "++a" (which is 12) is passed as the third argument, the value of "a++" (which is 11) is passed as the second argument, and the value of "a" (which is 11 after the increment) is passed as the first argument. Therefore, the output is "12 11 11".

    Rate this question:

  • 3. 

    What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){   int x=5,y=10,z=15;   printf("%d %d %d");   return 0; }

    • A.

      Garbage Garbage Garbage

    • B.

      5 10 15

    • C.

      15 10 5

    • D.

      Compiler error

    • E.

      Run time error

    Correct Answer
    D. Compiler error
    Explanation
    The code will result in a compiler error because the printf function is missing the required format specifier arguments. The code is trying to print three integers, but there are no corresponding format specifiers in the printf statement.

    Rate this question:

  • 4. 

    What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){   register int i,x;   scanf("%d",&i);   x=++i + ++i + ++i;   printf("%d",x);   return 0; }

    • A.

      17

    • B.

      18

    • C.

      21

    • D.

      22

    • E.

      Compiler error

    Correct Answer
    E. Compiler error
    Explanation
    The code will result in a compiler error. This is because the register keyword is used to suggest that the variable should be stored in a CPU register for faster access. However, the use of multiple increment operators (++i) on the same variable in the same statement leads to undefined behavior. Therefore, the code is not valid and will not compile successfully.

    Rate this question:

  • 5. 

    What will be output if you will compile and execute the following c code? #include int main(){   int a=5;   int b=10;   {     int a=2;     a++;     b++;   }   printf("%d %d",a,b);   return 0; }

    • A.

      5 10

    • B.

      6 11

    • C.

      5 11

    • D.

      6 10

    • E.

      Complier error

    Correct Answer
    C. 5 11
    Explanation
    The code declares two integer variables, a and b, and initializes them with the values 5 and 10 respectively. Then, a new block is created using curly braces, within which a new integer variable a is declared and initialized with the value 2. The value of this inner variable a is then incremented by 1 and the value of b is also incremented by 1. Finally, outside of the block, the values of a and b are printed using printf. Since the inner variable a has a limited scope within the block, the value of the outer variable a remains unchanged at 5, while the value of b is incremented to 11. Therefore, the output will be "5 11".

    Rate this question:

  • 6. 

    Which of the following type of class allows only one object of it to be created?

    • A.

      Virtual class

    • B.

      Abstract class

    • C.

      Singleton class

    • D.

      Friend class

    Correct Answer
    C. Singleton class
    Explanation
    A Singleton class allows only one object of it to be created. This is achieved by making the constructor of the class private, preventing any other class from creating multiple instances of it. The class itself provides a static method that returns the single instance of the class, ensuring that only one object is created and shared across the application. This pattern is commonly used in scenarios where having multiple instances of a class could cause issues or is unnecessary.

    Rate this question:

  • 7. 

    Which of the following is not a type of constructor?

    • A.

      Copy constructor

    • B.

      Friend constructor

    • C.

      Default constructor

    • D.

      Parameterized constructor

    Correct Answer
    B. Friend constructor
    Explanation
    A friend constructor is not a type of constructor in C++. Friend functions are used to access private and protected members of a class from outside the class. However, constructors are special member functions used to initialize objects of a class. They have the same name as the class and are automatically called when an object is created. Therefore, a friend constructor does not exist in C++ and is not a valid type of constructor.

    Rate this question:

  • 8. 

    Which of the following concepts means determining at runtime what method to invoke?

    • A.

      Data hiding

    • B.

      Dynamic Typing

    • C.

      Dynamic binding

    • D.

      Dynamic loading

    Correct Answer
    C. Dynamic binding
    Explanation
    Dynamic binding refers to the process of determining at runtime which method to invoke based on the actual type of the object, rather than the declared type. This allows for flexibility and polymorphism in object-oriented programming, as different objects can have different implementations of the same method. By dynamically binding the method at runtime, the appropriate implementation is chosen based on the specific object being used.

    Rate this question:

  • 9. 

    Which of the following concept of oops allows compiler to insert arguments in a function call if it is not specified?

    • A.

      Call by value

    • B.

      Call by reference

    • C.

      Default arguments

    • D.

      Call by pointer

    Correct Answer
    C. Default arguments
    Explanation
    Default arguments in object-oriented programming (OOP) allow the compiler to automatically insert values for function arguments if they are not specified by the caller. This means that the function can be called without providing values for all the arguments, and the compiler will use the default values defined in the function declaration. This concept provides flexibility and convenience, as it allows for more concise function calls by eliminating the need to specify all arguments every time the function is called.

    Rate this question:

  • 10. 

    Which of the following is correct about the statements given below?
    1. All operators can be overloaded in C++.
    2. We can change the basic meaning of an operator in C++.

    • A.

      Only I is true.

    • B.

      Both I and II are false.

    • C.

      Only II is true.

    • D.

      Both I and II are true.

    Correct Answer
    B. Both I and II are false.
    Explanation
    The correct answer is "Both I and II are false." This means that neither statement is correct. In C++, not all operators can be overloaded. There are certain operators that cannot be overloaded, such as the `.` (dot) operator and the `::` (scope resolution) operator. Additionally, while operator overloading allows us to redefine the behavior of an operator, it does not change its basic meaning. The basic meaning of an operator is defined by the language itself and cannot be changed.

    Rate this question:

  • 11. 

    • A.

      L

    • B.

      Q

    • C.

      N

    • D.

      D

    Correct Answer
    B. Q
  • 12. 

    Look at this series: 2, 1, (1/2), (1/4), ... What number should come next?

    • A.

      (1/3)

    • B.

      (1/8)

    • C.

      (2/8)

    • D.

      (1/16)

    Correct Answer
    B. (1/8)
    Explanation
    The series is formed by dividing each number by 2. Starting with 2, we divide by 2 to get 1, then divide by 2 again to get 1/2, and so on. Therefore, the next number should be 1/8, which is obtained by dividing 1/4 by 2.

    Rate this question:

  • 13. 

    Look at this series: 7, 10, 8, 11, 9, 12, ... What number should come next?

    • A.

      7

    • B.

      10

    • C.

      12

    • D.

      13

    Correct Answer
    B. 10
    Explanation
    The series alternates between adding 3 and subtracting 2. Starting with 7, we add 3 to get 10. Then, we subtract 2 to get 8. Next, we add 3 again to get 11. This pattern continues, so the next number should be obtained by subtracting 2 from 11, resulting in 9. Therefore, the correct answer is 9.

    Rate this question:

  • 14. 

    Look carefully for the pattern, and then choose which pair of numbers comes next. 28 25 5 21 18 5 14

    • A.

      11 5

    • B.

      10 7

    • C.

      11 8

    • D.

      5 10

    • E.

      10 5

    Correct Answer
    A. 11 5
    Explanation
    The pattern in the given sequence is that the first number in each pair is obtained by subtracting 3 from the previous number, while the second number in each pair is obtained by subtracting 16 from the previous number. Applying this pattern, the next pair of numbers should be 11 (18 - 3 = 15, 15 - 3 = 12, 12 - 3 = 9, 9 - 3 = 6, 6 - 3 = 3, 3 - 3 = 0, 0 - 3 = -3, -3 - 3 = -6, -6 - 3 = -9, -9 - 3 = -12, -12 - 3 = -15, -15 - 3 = -18, -18 - 3 = -21, -21 - 3 = -24, -24 - 3 = -27, -27 - 3 = -30, -30 - 3 = -33, -33 - 3 = -36, -36 - 3 = -39, -39 - 3 = -42, -42 - 3 = -45, -45 - 3 = -48, -48 - 3 = -51, -51 - 3 = -54, -54 - 3 = -57, -57 - 3 = -60, -60 - 3 = -63, -63 - 3 = -66, -66 - 3 = -69, -69 - 3 = -72, -72 - 3 = -75, -75 - 3 = -78, -78 - 3 = -81, -81 - 3 = -84, -84 - 3 = -87, -87 - 3 = -90, -90 - 3 = -93, -93 - 3 = -96, -96 - 3 = -99, -99 - 3 = -102, -102 - 3 = -105, -105 - 3 = -108, -108 - 3 = -111, -111 - 3 = -114, -114 - 3 = -117, -117 - 3 = -120, -120 - 3 = -123, -123 - 3 = -126, -126 - 3 = -129, -

    Rate this question:

  • 15. 

    Look carefully for the pattern, and then choose which pair of numbers comes next. 9 11 33 13 15 33 17

    • A.

      33 35

    • B.

      19 33

    • C.

      33 19

    • D.

      15 33

    • E.

      19 21

    Correct Answer
    B. 19 33
    Explanation
    The pattern in the given sequence is that the numbers alternate between increasing by 2 and increasing by 4. The first number increases by 2, the second number increases by 4, and so on. Following this pattern, the next pair of numbers should be 19 and 33, as 19 is obtained by adding 2 to the previous number (17), and 33 is obtained by adding 4 to the previous number (19).

    Rate this question:

  • 16. 

    A is thrice as good as workman as B and therefore is able to finish a job in 60 days less than B. Working together, they can do it in:

    • A.

      20 days

    • B.

      22.5 days

    • C.

      25 days

    • D.

      30 days

    Correct Answer
    B. 22.5 days
    Explanation
    A is three times as efficient as B, meaning that A can complete three times the amount of work that B can in the same amount of time. Therefore, if B takes x days to complete the job, A will take x/3 days. It is given that A can finish the job in 60 days less than B, so we can set up the equation x - 60 = x/3. Solving this equation gives us x = 90, meaning that B takes 90 days to complete the job. Working together, their combined efficiency is 1/x + 1/(x/3) = 1/90 + 3/90 = 4/90 = 1/22.5. Therefore, they can complete the job together in 22.5 days.

    Rate this question:

  • 17. 

    A, B and C can do a piece of work in 20, 30 and 60 days respectively. In how many days can A do the work if he is assisted by B and C on every third day?

    • A.

      12 days

    • B.

      15 days

    • C.

      16 days

    • D.

      18 days

    Correct Answer
    B. 15 days
    Explanation
    A can do the work in 20 days, while B and C can do it in 30 and 60 days respectively. This means that in 20 days, A completes 1/20th of the work, while B and C complete 1/30th and 1/60th of the work respectively. When A is assisted by B and C on every third day, they work together for a total of 6 days (2 days for A, 2 days for B, and 2 days for C). In these 6 days, they complete 1/20th + 1/30th + 1/60th = 1/10th of the work. Therefore, in 60 days (6 days x 10), they would complete the entire work. Since A is working for 2 out of every 6 days, it would take him 60/3 = 20 days to complete the work on his own.

    Rate this question:

  • 18. 

    4 men and 6 women can complete a work in 8 days, while 3 men and 7 women can complete it in 10 days. In how many days will 10 women complete it?

    • A.

      35

    • B.

      50

    • C.

      45

    • D.

      40

    Correct Answer
    D. 40
    Explanation
    The given information states that 4 men and 6 women can complete the work in 8 days, while 3 men and 7 women can complete it in 10 days. This implies that the work done by the men and women is inversely proportional to the number of days taken to complete the work. By comparing the two scenarios, it can be deduced that the work done by 1 man is equal to the work done by 2 women. Therefore, the work done by 10 women is equal to the work done by 5 men. Since the work done by 4 men and 6 women is equal, it can be concluded that 10 women will complete the work in the same time as 4 men, which is 40 days.

    Rate this question:

  • 19. 

    10 women can complete a work in 7 days and 10 children take 14 days to complete the work. How many days will 5 women and 10 children take to complete the work?

    • A.

      3

    • B.

      5

    • C.

      7

    • D.

      Cannot be determined

    • E.

      None of these

    Correct Answer
    C. 7
    Explanation
    10 women can complete the work in 7 days, which means that the work done by 1 woman in 1 day is 1/70. Similarly, 10 children can complete the work in 14 days, so the work done by 1 child in 1 day is 1/140. To find how many days 5 women and 10 children will take to complete the work, we need to calculate the combined work done by them in 1 day. 5 women will do 5/70 of the work in 1 day, and 10 children will do 10/140 of the work in 1 day. Adding these two fractions, we get (5/70) + (10/140) = 1/14. Therefore, 5 women and 10 children will take 14 days to complete the work. Since this option is not available, the answer is 7 days.

    Rate this question:

  • 20. 

    X and Y can do a piece of work in 20 days and 12 days respectively. X started the work alone and then after 4 days Y joined him till the completion of the work. How long did the work last?

    • A.

      6 days

    • B.

      10days

    • C.

      15days

    • D.

      20days

    Correct Answer
    B. 10days
    Explanation
    X can complete 1/20th of the work in a day, while Y can complete 1/12th of the work in a day. X worked alone for 4 days, completing 4/20th of the work. Then, X and Y worked together, completing 1/20th + 1/12th = 8/60th of the work in a day. To complete the remaining 16/60th of the work, it took them 16/8 = 2 days. Therefore, the total time taken to complete the work is 4 + 2 = 6 days.

    Rate this question:

  • 21. 

    It was Sunday on Jan 1, 2006. What was the day of the week Jan 1, 2010?

    • A.

      Sunday

    • B.

      Saturday

    • C.

      Friday

    • D.

      Wednesday

    Correct Answer
    C. Friday
    Explanation
    The question asks for the day of the week on January 1, 2010, given that January 1, 2006, was a Sunday. To find the day of the week, we need to count the number of days between the two dates. There are 365 days in a year, so from 2006 to 2010, there are 4 years, which is a total of 4 x 365 = 1460 days. Since 1460 is divisible by 7, the day of the week will be the same. Therefore, January 1, 2010, will also be a Sunday.

    Rate this question:

  • 22. 

    The calendar for the year 2007 will be the same for the year:

    • A.

      2014

    • B.

      2016

    • C.

      2017

    • D.

      2018

    Correct Answer
    D. 2018
    Explanation
    The calendar for the year 2007 will be the same for the year 2018 because there is a pattern in the calendar where the days of the week repeat every 11 years. Since 2007 and 2018 are 11 years apart, the calendar will be the same.

    Rate this question:

  • 23. 

    Which one of the following is not a prime number?

    • A.

      31

    • B.

      61

    • C.

      71

    • D.

      91

    Correct Answer
    D. 91
    Explanation
    91 is not a prime number because it is divisible by 7 and 13. A prime number is a number that is only divisible by 1 and itself, and 91 does not meet this criteria.

    Rate this question:

  • 24. 

    The banker's discount on a bill due 4 months hence at 15% is Rs. 420. The true discount is:

    • A.

      Rs. 400

    • B.

      Rs. 360

    • C.

      Rs. 480

    • D.

      Rs. 320

    Correct Answer
    A. Rs. 400
    Explanation
    The banker's discount is the interest charged by the bank on the face value of the bill for the period until it matures. In this question, the banker's discount is given as Rs. 420. The true discount is the difference between the face value of the bill and the amount received by the bank. Since the banker's discount is 15% of the face value, we can calculate the face value by dividing the banker's discount by the rate of interest. Rs. 420 / 0.15 = Rs. 2800. The true discount is then the difference between the face value and the amount received, which is Rs. 2800 - Rs. 2400 = Rs. 400. Therefore, the correct answer is Rs. 400.

    Rate this question:

  • 25. 

    A person crosses a 600 m long street in 5 minutes. What is his speed in km per hour?

    • A.

      3.6

    • B.

      7.2

    • C.

      8.4

    • D.

      10

    Correct Answer
    B. 7.2
    Explanation
    To calculate the speed in km per hour, we need to convert the distance from meters to kilometers and the time from minutes to hours. There are 1000 meters in a kilometer, so the distance is 0.6 km. There are 60 minutes in an hour, so the time is 1/12 hours. Dividing the distance by the time gives us a speed of 7.2 km per hour.

    Rate this question:

Quiz Review Timeline +

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

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 22, 2013
    Quiz Created by
    Sscet
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.