Vidyalelo
C Programming · all questions

Arrays and Strings
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

133

Questions

3/7

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following code?
void main()
{
      int a[10];
      printf("%d %d", a[-1], a[12]);
}

Select an option to see the answer and solution.

What does the following declaration mean?
int (*ptr)[10];

Select an option to see the answer and solution.

Array passed as an argument to a function is interpreted as

Select an option to see the answer and solution.

What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?
#include<stdio.h>
void main()
{
    int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};
    printf("%u, %u", a+1, &a+1);
}

Select an option to see the answer and solution.

What will be the output of the program?
#include<stdio.h>
int main()
{
    int arr[1] = {10};
    printf("%d", 0[arr]);
    return 0;
}

Select an option to see the answer and solution.

What will be the output of the program if the array begins at address 65486?
#include<stdio.h>
void main()
{
    int arr[] = {12, 14, 15, 23, 45};
    printf("%u, %u", arr, &arr);
}

Select an option to see the answer and solution.

What will be the output of the program?
#include<stdio.h>
void main()
{
    float arr[] = {12.4, 2.3, 4.5, 6.7};
    printf("%d", sizeof(arr)/sizeof(arr[0]));
}

Select an option to see the answer and solution.

Which of the following is correct way to define the function fun() in the below program?
#include<stdio.h>
void main()
{
    int a[3][4];
    fun(a);
}

Select an option to see the answer and solution.

Which of the following statements are correct about the program below?
#include<stdio.h>
void main()
{
    int size, i;
    scanf("%d", &size);
    int arr[size];
    for(i=1; i<=size; i++)
    {
        scanf("%d", arr[i]);
        printf("%d", arr[i]);
    }
}

Select an option to see the answer and solution.

Which of the following statements are correct about an array?
1. The array int num[26]; can store 26 elements.
2. The expression num[1] designates the very first element in the array.
3. It is necessary to initialize the array at the time of declaration.
4. The declaration num[SIZE] is allowed if SIZE is a macro.

Select an option to see the answer and solution.

If the two strings are identical, then strcmp() function returns

Select an option to see the answer and solution.

The library function used to find the last occurrence of a character in a string is

Select an option to see the answer and solution.

Which of the following function is used to find the first occurrence of a given string in another string?

Select an option to see the answer and solution.

Which of the following function is more appropriate for reading in a multi-word string?

Select an option to see the answer and solution.

What will be the output of the program?
#include<stdio.h>
#include<string.h>
void main()
{
    char str1[20] = "Hello", str2[20] = " World";
    printf("%s", strcpy(str2, strcat(str1, str2)));
}

Select an option to see the answer and solution.

What will be the output of the program?
#include<stdio.h>
void main()
{
    printf(5+"Good Morningn");
}

Select an option to see the answer and solution.

What will be the output of the program?
#include<stdio.h>
#include<string.h>
void main()
{
    char str[] = "Exam\0Veda";
    printf("%s", str);
}

Select an option to see the answer and solution.

Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?

Select an option to see the answer and solution.

What is the return value of the following statement if it is placed in C program? strcmp("ABC", "ABC");

Select an option to see the answer and solution.

int a[5] = {1,2,3}
What is the value of a[4]?

Select an option to see the answer and solution.