wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

UNIT-3 Arrays Worksheet — Extracted Questions

Total questions: 54

Worksheet time: 27mins

Name
Class
Date
1.

Write a C-program to read and print array elements. Choose the option that correctly declares an integer array of size 10, reads 10 integers from standard input, and then prints them.

a)

int a[10], i; for(i=0;i<10;i++){ scanf("%d", &a[i]); } for(i=0;i<10;i++){ printf("%4d", a[i]); }

b)

int a[10], i; for(i=0;i<=10;i++){ scanf("%d", &a[i]); } for(i=0;i<=10;i++){ printf("%d", a[i]); }

c)

int a[9], i; for(i=0;i<9;i++){ scanf("%d", &a[i]); } for(i=0;i<9;i++){ printf("%d", a[i]); }

d)

int a[10], i; for(i=0;i<10;i++){ scanf("%d", &a); } for(i=0;i<10;i++){ printf("%d", &a[i]); }

2.

Write a C-program to read and print your name. Which option matches the worksheet’s example that declares a character array and prints the stored name as a string?

a)

char name[20]="vijaya"; printf("My name is : %s", name);

b)

char name[5]="vijaya"; printf("My name is : %s", name);

c)

char name[20]; scanf("%c", &name); printf("My name is : %c", name);

d)

char name[20]="vijaya"; printf("My name is : %d", name);

3.

Examples on Two-dimensional array — Read and print array elements using 2-D: Identify the task performed by the given C program with nested loops and scanf/printf around a 2×2 integer array.

a)

Reads elements into a 2-D array and then prints all elements

b)

Sorts the elements of a 2-D array in ascending order

c)

Generates the first 10 Fibonacci numbers

d)

Prints elements of a 1-D array in reverse order

4.

Multidimensional arrays: According to the description, how does C conceptually view a three-dimensional array?

a)

As an array of arrays of arrays

b)

As a single continuous linked list

c)

As a matrix of pointers to rows only

d)

As a tree of nodes with child arrays

5.

Multidimensional arrays: What term is used to describe the first dimension, which consists of rows and columns?

a)

Plane

b)

Row

c)

Column

d)

Layer

6.

Declaring multidimensional arrays: For a fixed-length array declaration in C, what must be known at compilation time?

a)

The size of each dimension must be a constant

b)

The initial values for every element

c)

The runtime input values

d)

The memory addresses of all elements

7.

Declaring multidimensional arrays: Which declaration matches the described syntax for a three-dimensional integer array named table?

a)

int table[planes][rows][cols];

b)

double table(rows, cols);

c)

int table[rows][cols];

d)

int table{planes, rows, cols};

8.

Initialization: Given the example int table[3][5][4]={…}, what are the sizes of the three dimensions in order?

a)

3, 5, 4

b)

5, 4, 3

c)

4, 5, 3

d)

3, 4, 5

9.

Finding number of words in a sentence: Identify the task performed by the program that reads a sentence and updates a counter before printing the result.

a)

Counts the number of words in the sentence

b)

Counts the number of characters in the sentence

c)

Converts the sentence to uppercase

d)

Reverses the sentence

10.

Sample program printing Elements, Index, Address: What does the program print for each entered array element?

a)

The element’s value, its index, and its memory address

b)

Only the element’s value

c)

Only the element’s memory address

d)

The sum and average of all elements

11.

Asending order: What ordering does the sorting program produce for the ten entered numbers?

a)

Ascending order

b)

Descending order

c)

Random order

d)

Original input order

12.

Write C program to generate first 10 fibonacci numbers: What sequence does the program produce and print?

a)

The first 10 Fibonacci numbers

b)

The first 10 prime numbers

c)

Factorials from 1 to 10

d)

Squares of numbers from 1 to 10

13.

Read array elements and print them into reverse order: After reading ten integers, what does the program output?

a)

All elements in reverse order

b)

All elements in ascending order

c)

Only distinct elements

d)

Only memory addresses of elements

14.

Largest and smallest: From the ten entered integers, what does the program compute and print?

a)

The largest and the smallest values

b)

Only the average value

c)

Only the sum of all values

d)

The median value

15.

String conversion with uppercase input: Given a string entered in uppercase, what transformation does the program apply to its alphabetical characters?

a)

Converts uppercase letters to lowercase

b)

Converts lowercase letters to uppercase

c)

Reverses the entire string

d)

Encrypts the string with a cipher

16.

In C, a string is a variable‑length array of characters that is delimited by a specific character. What character terminates a C string?

a)

A space

b)

A newline

c)

A tab

d)

A null character

17.

Why is a null character required at the end of a C string?

a)

Because a string is stored as a logical data structure that needs a delimiter to mark its end

b)

Because arrays in C cannot store spaces without an extra marker

c)

Because C automatically appends a newline unless a null character is used

d)

Because pointers cannot reference the last element

18.

Which statement distinguishes a C string from a character array, as shown by H E L L O \0 versus H E L L O?

a)

A character array must always contain digits

b)

A C string is terminated by a null character, while a character array may not be

c)

A character array cannot store uppercase letters

d)

A C string cannot include spaces

19.

Which of the following is a C string literal?

a)

"Hello"

b)

'H'

c)

Hello (without quotes)

d)

"H" (single quote)

20.

According to the diagram of string concepts, how is Variable length categorized?

a)

Only Fixed length

b)

Length controlled and Delimited

c)

Fixed length and Pointer

d)

Delimited only

21.

When implementing a fixed‑length string format, what is the first decision?

a)

The delimiter to use

b)

The size of the variable

c)

The pointer type

d)

The compiler version

22.

In variable‑length strings, what is the main advantage stated?

a)

They force a fixed buffer that prevents overflow

b)

They allow using only the required memory, reducing wastage and data losses

c)

They automatically convert to integers

d)

They prevent the need for a null terminator

23.

What do length‑controlled strings add?

a)

A count specifying the number of characters in the string

b)

A trailing newline

c)

A leading tab

d)

A second delimiter

24.

In delimited strings, how is the end of the string identified?

a)

By a count field

b)

By a delimiter at the end

c)

By a fixed array size

d)

By a pointer cast

25.

How can data be stored, according to Strings and characters?

a)

Only as integers

b)

As character literal or as string literal

c)

Only as arrays of pointers

d)

Only as double‑quoted text

26.

Which quoting is used for a character literal versus a string literal?

a)

Character literal uses double quotes; string literal uses single quotes

b)

Character literal uses single quotes; string literal uses double quotes

c)

Both use double quotes

d)

Both use single quotes

27.

Which declaration defines memory for a string as a local array?

a)

char *pstr;

b)

char str[9];

c)

int str[9];

d)

char **pstr;

28.

What is noted about strings when initializing them as arrays or pointers?

a)

Strings end with a newline

b)

Strings end with a null character

c)

Strings begin with a tab

d)

Strings require numeric indexes only

29.

Which two families provide formatted input and output of strings?

a)

gets/fgets and puts/fputs

b)

scanf/fscanf and printf/fprintf

c)

read/write and open/close

d)

strcpy/strcat and strlen

30.

Which are special string‑only functions for input and output?

a)

gets/fgets

b)

puts/fputs

c)

scanf/printf

d)

read/write

31.

What does the statement scanf("%s", str); accomplish?

a)

Writes the contents of str to the screen

b)

Reads a string from the keyboard into str

c)

Converts str to uppercase

d)

Allocates memory for str

32.

What is described about gets()?

a)

It reads characters until a newline and appends a null terminator; the newline is not added to the string

b)

It reads only one character and returns it

c)

It writes a string to the screen

d)

It reads numeric input only

33.

What is described about puts()?

a)

It prints a string message to the output screen and can display the stored string in a variable

b)

It reads a string from the keyboard

c)

It compares two strings

d)

It allocates a buffer

34.

Which functions are listed as character input functions for reading a single character at a time from the keyboard?

a)

getchar()

b)

getche()

c)

getch()

d)

puts()

35.

According to the description, what does getch() do?

a)

Reads a character and echoes it on the screen

b)

Reads the character from the keyboard and passes it immediately to the program with echoing on the screen

c)

Reads a line into a buffer

d)

Converts a character to uppercase

36.

Which statement matches getchar()?

a)

Accepts a character and displays the same character on the screen

b)

Reads a character, assigns it to a variable, and stores it

c)

Writes the stored character to the screen

d)

Reads a string until a newline

37.

What is described about getche()?

a)

Accepts a character and passes it to the program while also echoing the same character on the screen

b)

Reads a string without echo

c)

Compares two characters

d)

Allocates memory for a character

38.

What is the role of putchar()?

a)

To read a character from the keyboard

b)

To print the stored character in a variable to the screen

c)

To compare two characters

d)

To convert characters to lowercase

39.

Which standard C string library function determines the length of a string?

a)

strcpy()

b)

strlen()

c)

strcmp()

d)

strdup()

40.

Which function compares two strings without discriminating between small and capital letters?

a)

strcmp()

b)

stricmp()

c)

strlwr()

d)

strdup()

41.

Which function converts uppercase letters to lowercase letters?

a)

strlwr()

b)

strupr()

c)

strcpy()

d)

strlen()

42.

Which function converts lowercase letters to uppercase letters?

a)

strlwr()

b)

strupr()

c)

strncpy()

d)

strcmp()

43.

Which C library function returns the number of characters in a string as an integer?

a)

strlen()

b)

strcpy()

c)

strcat()

d)

strcmp()

44.

In the syntax strcpy(stringvariable,stringvariable1), which position is the source string that contains the data to be copied?

a)

First position

b)

Second position

c)

Both positions

d)

Neither position

45.

Which function is used to concatenate two strings, storing the combined result in the destination string?

a)

strcat()

b)

strcpy()

c)

strcmp()

d)

strrev()

46.

The strcmp(stringvariable1,stringvariable2) function returns an integer. Which result indicates that both strings are equal?

a)

Positive value

b)

Negative value

c)

Zero

d)

Undefined

47.

For strcmp(str1,str2), which sign of the return value indicates that str1 is greater than str2?

a)

Positive

b)

Negative

c)

Zero

d)

No return value

48.

Which function is used to reverse a given string?

a)

strrev()

b)

strlwr()

c)

strupr()

d)

strcat()

49.

Which function converts an uppercase string to lowercase?

a)

strlwr()

b)

strupr()

c)

strrev()

d)

strcmp()

50.

Which function converts a lowercase string to uppercase?

a)

strupr()

b)

strlwr()

c)

strrev()

d)

strcat()

51.

In the sample program that checks whether a string is a palindrome using strcpy, strrev, and strcmp, which value of i from i=strcmp(str,str1) indicates the string is a palindrome?

a)

0

b)

1

c)

-1

d)

A positive value

52.

Which function is used to find the first occurrence of one string inside another string to determine whether a word is present?

a)

strstr()

b)

strchr()

c)

strrchr()

d)

strrev()

53.

According to the listed functions, which one gives the last character of the given string?

a)

strrchr()

b)

strchr()

c)

strspn()

d)

strcat()

54.

According to the listed functions, which one finds up to what length two strings are identical?

a)

strspn()

b)

strcmp()

c)

strrchr()

d)

strrev()