C quiz

C quiz

University

10 Qs

quiz-placeholder

Similar activities

JAVA - Arrays

JAVA - Arrays

University - Professional Development

15 Qs

Array in C

Array in C

University

10 Qs

Bootcamp Day 3 - Java Array

Bootcamp Day 3 - Java Array

University

15 Qs

CS6801- Multi­core Architectures and Programming

CS6801- Multi­core Architectures and Programming

University

10 Qs

Common errors in C programming

Common errors in C programming

University

15 Qs

Quiz - 1

Quiz - 1

University

8 Qs

java

java

University - Professional Development

8 Qs

FODS-Program Basics

FODS-Program Basics

University

15 Qs

C quiz

C quiz

Assessment

Quiz

Computers

University

Hard

Created by

Giri A

Used 5+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <stdio.h>

int main() {

int arr[] = {10, 20, 30, 40, 50};

int *ptr = arr;

ptr = ptr + 2;

printf("%d ", *(ptr + 1));

return 0;

}

30

40

50

20

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <stdio.h>

#include <string.h>

int main() {

char str[] = "Hello, world!";

printf("%d", strlen(str));

return 0;

}

13

14

12

Undefined behaviour

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <stdio.h>

#include <stdlib.h>

int main() {

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

arr[1] = 10;

arr[2] = 20;

free(arr);

printf("%d", arr[2]);

return 0;

}

0

10

20

Undefined behavior

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <stdio.h>

#include <stdlib.h>

int main() {

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

free(arr);

arr[0] = 5;

printf("%d", arr[0]);

return 0;

}


It will print 5.

It will print 0.

It will give a runtime error due to accessing freed memory.

It will give a compilation error.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <stdio.h>

int main() {

int x = 5; // Binary: 0101

x = x << 1;

printf("%d", x);

return 0;

}

5

10

20

2

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <stdio.h>

struct Person {

char name[30];

int age;

}

int main() {

struct Person persons[2] = {{"John", 25}, {"Jane", 30}};

printf("%d", persons[1].age);

return 0;

}

persons[1].name

persons[0].age

persons[1].age

persons[0].name

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

#include <stdio.h>

int main() {

for (int i = 0; i >= 0; i++) {

printf("%d ", i);

}

return 0;

}

The loop will terminate after one iteration.

The loop will run forever.

The loop will run 0 iterations.

It will cause a segmentation fault.

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?