Search Header Logo

C Programming Quiz unit 2

Authored by MS CHAUHAN

Computers

University

Used 1+ times

C Programming Quiz unit 2
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

55 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the correct syntax for a for loop in C?

for (initialization; condition; increment) { ... }

for (condition; initialization; increment) { ... }

for initialization; condition; increment { ... }

for (initialization condition increment) { ... }

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

How many times will the following loop execute? c int i = 0; while (i < 5) { i++; }

4

5

6

Infinite loop

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which statement should be used to skip the current iteration in a loop in C?

break;

continue;

goto;

exit;

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What will be the output for the following code? c for(int i=1; i<=3; i++) { for(int j=1; j<=i; j++) { printf("*"); } printf("\n"); }

text *** *** ***

text * ** ***

text * * *

text ** *** ****

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the valid declaration for a 2D integer array with 3 rows and 4 columns?

int arr[3][4];

int arr[4][3];

int arr[3];

int arr[4];

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

How is the address of arr[i][j] in a 2D array (row-major order) calculated (assuming array is declared as int arr[M][N];)

base_address + (i*N + j) * sizeof(int)

base_address + (j*M + i) * sizeof(int)

base_address + (j*N + i) * sizeof(int)

base_address + (i*M + j) * sizeof(int)

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following correctly initializes a string in C?

char str[] = "Hello";

char str = "Hello";

Both A and B

char str = "Hello";

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?