C-Volution (Hard)

C-Volution (Hard)

University

10 Qs

quiz-placeholder

Similar activities

Python Programming Competition

Python Programming Competition

University

12 Qs

Assembly Language and MIPS Architecture Quiz

Assembly Language and MIPS Architecture Quiz

University

15 Qs

conditional statements and While Loop

conditional statements and While Loop

University

11 Qs

aula 3 - IC

aula 3 - IC

University

10 Qs

PYTHON APTITUDE

PYTHON APTITUDE

University

12 Qs

Java_MCQ_3

Java_MCQ_3

University

15 Qs

Python Loop

Python Loop

University

15 Qs

Condition Programming Quiz

Condition Programming Quiz

1st Grade - University

9 Qs

C-Volution (Hard)

C-Volution (Hard)

Assessment

Quiz

Information Technology (IT)

University

Hard

Created by

Sujal Bhagat

Used 1+ times

FREE Resource

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

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?