Search Header Logo

C-Volution (Hard)

Authored by Sujal Bhagat

Information Technology (IT)

University

Used 1+ times

C-Volution (Hard)
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 3 pts

What is the output of the following code? #include int main() { int i, j; for (i = 1; i <= 5; i++) { for (j = 1; j <= i; j++) { printf("%d ", j); } printf("\n"); } return 0; }

1 1 2 1 2 3 1 2 3 4 1 2 3 4 5

1 2 2 3 3 3 4 4 4 4 5 5 5 5 5

1 2 3 4 5 1 2 3 4 1 2 3 1 2 1

1 2 3 4 5 2 3 4 5 3 4 5 4 5 5

2.

MULTIPLE CHOICE QUESTION

1 min • 3 pts

What is the output of the following code? #include int main() { int i, j; for (i = 5; i >= 1; i--) { for (j = 1; j <= i; j++) { printf("*"); } printf("\n"); } return 0; }

***** **** *** ** *

* ** *** **** *****

***** **** *** ** *

* ** *** **** *****

3.

MULTIPLE CHOICE QUESTION

1 min • 3 pts

What is the error in the following code? #include int main() { int *ptr; *ptr = 10; printf("%d\n", *ptr); return 0;}

Missing #include directive.

Dereferencing an uninitialized pointer.

Incorrect format specifier in printf().

No error.

4.

MULTIPLE CHOICE QUESTION

1 min • 3 pts

What does the following code snippet do? #define SQUARE(x) x * x

Defines a function named SQUARE.

Defines a macro named SQUARE.

Declares a variable named SQUARE.

Includes a header file named SQUARE.

5.

MULTIPLE CHOICE QUESTION

1 min • 3 pts

What is the output of the following code? #include int main() { int i, j; for (i = 1; i <= 4; i++) { for (j = 1; j <= 4; j++) { if (i + j == 5) { printf("*"); } else { printf(" "); } } printf("\n"); } return 0; }

* * * * * * *

**** **** **** ****

* * * *

Nothing will be printed.

6.

MULTIPLE CHOICE QUESTION

1 min • 3 pts

What is the correct way to dynamically allocate memory for an array of 10 integers?

int *arr = malloc(10 * sizeof(int));

int *arr = calloc(10, sizeof(int));

int *arr = new int[10];

Both (a) and (b)

7.

MULTIPLE CHOICE QUESTION

1 min • 3 pts

What is the output of the following code? #include int main() { int i = 1; do { printf("%d ", i); i++; } while (i <= 5); printf("\n"); return 0; }

1 2 3 4 5

1 2 3 4 5 6

1 2 3 4

Infinite loop

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?