C language MCQs - letsbug

MCQs On C Language  | Arrays, Loops, I/O and more

1. Which of the following is not a valid variable name declaration?

  1.  Int_a3;
  2.  int a_3;
  3.  int 3_a;
  4.  int_3a 

Answer: 3 : int 3_a;

2. All keywords in C are in ________ . 

  1.  Lowercase letters
  2.  Uppercase letters
  3.  Camelcase letters
  4.  None of the above.

Answer: 1 : Lowercase letters

3. The format identifier "%i" is also used for _________ data type.

  1. char
  2.  int
  3.  float
  4.  double

Answer: 2 : int.

4. Which of the following is a User-defined data type? 

  1. typedef int Boolean;
  2.  typedef enum {Mon, Tue, Wed, Thu, Fri} Wordays;
  3.  struct {char name[10], int age}
  4.  all of the mentioned

Answer: 4 : all of the mentioned

5.  What is the precedence of arithmetic operators ( from highest to lowest) ?

  1. %, * , / , +, -
  2.  %, +, /, *, -
  3.  +, -, %, *, /
  4.  %, +, -, *, /

Answer: 1 : %, *, /, +, -

6. putchar(c) function /macro always outputs character c to the ________ .

  1. screen
  2. standard output
  3. depends on the compiler
  4. depends on the standard

Answer: 2 : standard output

7. What is the Properties of first argument of a printf() functions?

  1.  It is defined by user.
  2.  It keeps the records of the types of arguments that will follow.
  3.  There may no be first argument.
  4.  None of the above mentioned.

Answer: 2 : It keeps the records of the types of arguments that will follow.

8. What is the purpose of sprintf?

  1. It prints the data into stdout.
  2. It writes  the formatted data into a string.
  3. It writes the formatted data into a file.
  4. None of the above.

Answer: 2 : It writes the formatted data into a string.

9. The syntax to print a % using printf statement can by done by ________. 

  1. %
  2. \%
  3. "%"
  4. %%

Answer: 4 : %%

10. Which among the following is the odd one out?

  1. printf
  2. fprintf
  3. putchar
  4. scanf

Answer: 4 : scanf

11. If c is a variable initialised to 1, how many times will the following loop be executed?

     while (c > 0 && (c, 60))
    {
      loop body
      c ++;
    }
  1. 60
  2. 59
  3. 61
  4. None of these

Answer: 2 : 59

12. A "switch" statement is used to

  1.  Switch between functions in a program
  2.  Switch from one variable to another variable
  3.  To choose from multiple possibilities which may arise due to different values of a single variable.
  4.  All of the above

Answer: 3 : To choose from multiple possibilities which may arise due to different values of a single variable.

13. choose the correct statement. 

  1.  Use of goto enhances the logical clarity of the code.
  2.  Use of goto makes the debugging task easier.
  3.  Use of goto when you want to jump out of a nested loop.
  4.  Never use goto statement. 

Answer: 3 : Use of goto when you want to jump out of a nested loop.

14. In a for loop, if the condition is missing then,

  1.  It is assumed to be present and taken to be false
  2.  it is assumed to be present and taken to be true.
  3.  it results in a syntax error.
  4.  execution will be terminated abruptly

Answer: 2 : It is assumed to be present and taken to be true.

15. Which of the following comments about a for loop are correct? 

  1. Index value is retained outside the loop and can be changed from within the loop
  2.  Body of the loop can by empty
  3.  goto can be used to jump out of loop.
  4.  All of the above.

Answer: 4 : All of the above.

16. What is right way of initialize array?

  1.  int num[6] = {2,4,12,5,45, 5};
  2.  int n{6} = {2, 4, 12};
  3.  int n{} = {2, 4, 12, 5, 45, 5};
  4.  int n(6)  = {2, 4, 12, 5, 45, 5};

Answer: 1 : int num[6] = {2, 4, 12, 5, 45, 5}

17. An array element are always stored in ________ memory locations.

  1.  Sequential 
  2.  Random
  3.  Sequential And Random
  4.  None of the above

Answer: 1 : Sequential

18. What is the maximum number of dimensions an array in C may have? 

  1.  Two
  2.  Eight
  3.  Sixteen 
  4.  Theoretically no limit. The only practical limit are memory size and compilers.

Answer: 4 : Theoretically no limit. The only practical limit are memory size and compilers.

19. What will be the address of the arr[2][3] if arr a 2D long array of 4 rows and 5 columns and starting address of the is 2000?

  1.  2048
  2.  2056 
  3.  2052
  4.  2042

Answer: 3 : 2052.

20. Size of the array need not be specified, when  

  1.  Initialization is a part of definition.
  2.  It is a formal parameter
  3.  It is a declaration
  4.  All of the above

Answer: 1 : Initialization is a part of definition.

Comments

Categories

Big Data Analytics Binary Search Binary Search Tree Binary To Decimal binary tree Breadth First Search Bubble sort C Programming c++ Chemical Reaction and equation class 10 class 10th Class 9 Climate Complex Numbers computer network counting sort CSS Cyber Offenses Cyber Security Cyberstalking Data Science Data Structures Decimal To Binary Development diamond pattern Digital Marketing dust of snow Economics Economics Lesson 4 Email Validation English fire and ice Food Security in India Footprints Without feet Forest And Wildlife Resources game Geography Geography lesson 6 glassmorphism Glossary Graph HackerRank Solution hindi HTML image previewer India-Size And Location Insertion Sort Internet Network Status Interview Questions Introduction to cyber crime and cyber security IT javascript tricks json to CSV converter lesson 2 lesson 1 lesson 2 Lesson 3 Lesson 6 lesson 7 Life lines of National Economy life processes Linear Search Linked List lowest common ancestor Machine Learning MCQs median in array Merge sort min and max of two numbers Moment Money and Credit My Childhood Natural Vegetation and Wildlife NCERT Network connectivity devices Network Models Network Security No Men Are foreign Node.js operator overloading P5.js PHP Physical features of India Population Prime Numbers python Quick sort R language Rain on the roof Regular Expression Resources and development reversing array saakhi science Searching Algorithm Selection sort Social Media Marketing social science Software Engineering Software Testing Sorting Algorithm Stacks staircase pattern System Concepts Text Recognition The last Leaf time converter Time Passed From A Date Todo List App Tree Trending Technologies Understanding Economic Development username and password video player Visualization water resources Wired And Wireless LAN साखी
Show more

Popular Posts

Big Data MCQs(multiple choice questions) with answers - letsbug

Digital Marketing MCQ(Multiple Choice Questions) with Answers | part 1 | letsbug

Software Engineering MCQs questions with answers - letsbug