Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

c++ online compiler MCQS

Rating
-
Sold
-
Pages
34
Grade
A
Uploaded on
03-01-2024
Written in
2023/2024

MULTIPLE CHOICE QUESTIONS C PROGRAMMING

Institution
Course

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

Written for

Course

Document information

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

Subjects

$4.49
Get access to the full document:

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

Get to know the seller
Seller avatar
haidernaeem

Get to know the seller

Seller avatar
haidernaeem Exam Questions
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
164
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

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