Search Header Logo

C String Array MCQs

Authored by Selvi Mathiyalakan

Computers

Professional Development

Used 2+ times

C String Array MCQs
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

2 mins • 10 pts

Predict the output of below program: #include <stdio.h> int main() { int arr[5]; // Assume that base address of arr is 2000 and size of integer // is 32 bit arr++; printf("%u", arr); return 0; }

2002
2004
2020
Lvalue Error
None

2.

MULTIPLE CHOICE QUESTION

2 mins • 10 pts

# 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
1 2 3 4 5 6 7 8
Compiler Error
1 2 3
None

3.

MULTIPLE CHOICE QUESTION

2 mins • 10 pts

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 0 0 0 0
1 1 1 1 1
1 Followed by garbage values
0 0 0 0 0
Compiler Error

4.

MULTIPLE CHOICE QUESTION

2 mins • 10 pts

int main() { int i; int arr[5] = {0}; for (i = 0; i <= 5; i++) printf("%d ", arr[i]); return 0; }

Compiler Error: Array index out of bound.
The always prints 0 five times followed by garbage value
The program always crashes
The program may print 0 five times followed by garbage value, or may crash if address (arr+5) is invalid
None

5.

MULTIPLE CHOICE QUESTION

2 mins • 10 pts

# include <stdio.h> int main() { char str1[] = "HelloWorld"; char str2[] = {'H', 'e', 'l', 'l', 'o', 'W', 'o', 'r', 'l','d'}; int n1 = sizeof(str1)/sizeof(str1[0]); int n2 = sizeof(str2)/sizeof(str2[0]); printf("n1 = %d, n2 = %d", n1, n2); return 0; }

n1=11,n2=10
n1=10,n2=11
n1=9,n2=11
n1=9,n2=10
None

6.

MULTIPLE CHOICE QUESTION

2 mins • 10 pts

#include<stdio.h> int main() { char str[20] = "Helloworld"; printf ("%d", sizeof(str)); return 0; }

9
11
20
Garbage value
Error

7.

MULTIPLE CHOICE QUESTION

2 mins • 10 pts

Output of following program? #include <stdio.h> int main() { int i = 5; printf("%d %d %d", i++, i++, i++); return 0; }

7 6 5
5 6 7
7 7 7
Compiler Dependent
None

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?