• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 34 pages
Exam (elaborations)

c++ online compiler MCQS

Document preview thumbnail
Preview 4 out of 34 pages

MULTIPLE CHOICE QUESTIONS C PROGRAMMING

Content preview

Here Are 100 Quizzes / Multiple-Choice Questions (Mcqs) Based On

C PROGRAMMING
With Correct Answers For 2023



1. What is the primary purpose of the "#include" directive in C?

a) Define a macro

b) Include a header file (Correct)

c) Declare a variable

d) Define a function



3. Which data type is used to store a single character in C?

a) char (Correct)

b) int

c) float

d) double



4. What is the maximum value that can be stored in an "unsigned int" data type?

a) 32767

b) 65535 (Correct)

c) 2147483647

d) 4294967295

,5. What will be the output of the following code snippet?

printf("%d", sizeof(int));


a) 4 (Correct)

b) 2

c) 8

d) Compiler error



6. In C, the expression "x += 5" is equivalent to:

a) x = x + 5 (Correct)

b) x = x - 5

c) x = 5

d) x = 0



7. Which loop is guaranteed to execute at least once?

a) for

b) while

c) do-while (Correct)

d) if



8. What is the purpose of the "break" statement in C?

a) Terminate the current loop iteration

, b) End the program

c) Skip the current iteration and continue the next one

d) Exit the loop or switch statement (Correct)



9. Which function is used to allocate memory dynamically in C?

a) malloc (Correct)

b) new

c) alloc

d) allocate



10. What is the correct way to declare a pointer to an integer in C?

a) int *p;

b) pointer p;

c) int ptr;

d) int &p;

(Correct)



11. Which keyword is used to define a constant in C?

a) constant

b) define

c) const (Correct)

d) constexpr

, 12. What is the purpose of the "strcpy" function in C?

a) Convert a string to uppercase

b) Concatenate two strings

c) Compare two strings

d) Copy one string to another (Correct)



13. What is the output of the following code snippet?

int x = 5; printf("%d", x++);

a) 5

b) 6 (Correct)

c) 4

d) Compiler error



14. What is the size of the "double" data type in bytes?

a) 4

b) 8 (Correct)

c) 16

d) Depends on the system



15. Which of the following is NOT a valid way to initialize an array in C?

a) int arr[] = {1, 2, 3};

Document information

Uploaded on
January 3, 2024
Number of pages
34
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers
$4.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
164
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions