Search Header Logo

Exploring 1D Array Loops

Authored by Bhawna Suri

Computers

University

Used 7+ times

Exploring 1D Array Loops
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What is a 1D array?

A 1D array is a linear collection of elements accessed by a single index.

A 1D array requires multiple indices to access elements.

A 1D array can only store integers.

A 1D array is a two-dimensional structure.

2.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

Write a loop to print all elements of a 1D array of length N in C

int i = 1;

while( i <N) { printf("%d\n",array[i]); }

int i = 0;

while(i < N) { printf("%d",array[i++]); }

for(int i = 0; i < N; i++ ) { printf("%d\n",array[i]); }

for(int i = 0; i <= N; i++ ) { printf("%d\n",array[i]); }

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

How can you find the length of a 1D array in C?

length = sizeof(array) / sizeof(array[0])

length = count(array)

length = array.length()

length = sizeof(array)

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What will be the output of the following code snippet: int arr[] = {1, 2, 3}; for(int i=0; i<3; i++) { printf("%d ", arr[i]); }?

1 2 3

3 2 1

1 2

2 3 4

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

void checkEvenOrNot(int num)

{

    if (num % 2 == 0)

        goto even;

else

       goto odd;

  

even:

    printf("%d is even", num);   return;

odd:

    printf("%d is odd", num); }

  

int main()

{

    int num = -2;

    checkEvenOrNot(num);

    return 0;

}

Output

error

-2 is even

-2 is odd

none of the above

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?

Discover more resources for Computers