Search Header Logo

Code Carnival

Authored by Kabhilan VS

Computers

University

Used 1+ times

Code Carnival
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

25 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code?


#include<stdio.h>

int main() {

    int x = 3;

    if (x == 3 || x == 2 * 2 && x != 5) {

        printf("Hello\n");

    } else { printf("World\n");

    }

    return 0;

}

Hello
World
Compilation Error
Hello World

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How many times will the loop execute? 


#include<stdio.h>

int main() {

    int i;

    for (i = 1; i <= 6; i++) {

        if (i % 2 == 0) {

            printf("%d ", i++);

        }

    }

   return 0;

}

2 4
2 3 6
2 4 6
Infinite loop

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code?


int arr[4] = {1, 2, 3};

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

0
3
Garbage value
Compilation error

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given the following declaration in C:

int arr[5];

float arr2[3];

Which of the following statements correctly calculates the total number of bytes required to store these arrays, considering the typical memory sizes for int and float (assuming int is 4 bytes and float is 4 bytes on your system)?

sizeof(arr) + sizeof(arr2)
sizeof(arr) * sizeof(arr2)
sizeof(arr) + sizeof(arr2)) / 2
(sizeof(arr) + sizeof(arr2)) - sizeof(int)

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code?


#include <stdio.h> 

int main() { 

    char str[5] = "Hello"; 

    printf("%s", str); 

    return 0; 

}

Hello
Compilation error
Undefined behavior
H

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output?  

int x = 10;  
switch (x) {  
    case 5: printf("Five");  
    case 10: printf("Ten");  
    case 15: printf("Fifteen");  
}  

Five
Ten
TenFifteen
Compilation error

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which function is used to find the length of a string?

strlen()
sizeof()
strlength()
length()

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

Microsoft

Continue with Microsoft

or continue with

Facebook

Facebook

Apple

Apple

Others

Others

Already have an account?