Search Header Logo

C- arrays , pointers and functions and macros MCQs

Authored by Shaik Imam

Professional Development

University

Used 11+ times

C- arrays , pointers and functions and macros  MCQs
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Predict the output of below program:Assume that base address of arr is 2000 and size of integer

is 32 bit

#include <stdio.h>

int main()

{

int arr[5];

arr++;

printf("%u", arr);

return 0;

}

2002

2004

2020

lvalue required

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output for a 64-bit Compiler?

# include <stdio.h>

void print(int arr[])

{

int n = sizeof(arr)/sizeof(arr[0]);

int i;

for (i = 0; i < n; i++)

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

}

int main()

{

int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};

print(arr);

return 0;

}

1, 2, 3, 4, 5, 6, 7, 8

Compiler Error

1 2

Run Time Error

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Predict the output of the below program:

#include <stdio.h>

#define SIZE(arr) sizeof(arr) / sizeof(*arr)

void fun(int* arr, int n)

{

    int i;

*arr += *(arr + n - 1) += 10;

}

void printArr(int* arr, int n)

{

    int i;

    for(i = 0; i < n; ++i)

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

}

int main()

{

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

    int size = SIZE(arr);

    fun(arr, size);

    printArr(arr, size);

    return 0;

}

20 30 40

20 20 40

50 20 40

Compile-time error

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Predict output of following program

int main()

{

    int i;

    int arr[5] = {1};

    for (i = 0; i < 5; i++)

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

    return 0;

}

1 followed by four garbage values

1 0 0 0 0

1 1 1 1 1

0 0 0 0 0

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following C code?

    #include <stdio.h>

    int main()

    {

        int one = 1, two = 2;

        #ifdef next

        one = 2;

        two = 1;

        #endif

        printf("%d, %d", one, two);

    }

2, 1

1, 2

1, 1

2, 2

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following C code?

#include<stdio.h>

void main(){

    #ifndef max

    printf("hello");

    #endif

    printf("hi");}

hellohi

hello

hi

error

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

. What will be the output of the following C code?

#include<stdio.h>

#define max 100

void main(){

    #if(max%10)

    printf("Bye");

    #endif

    printf("Hi");}

error

Bye

Hi

ByeHi

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?