Header Ads Widget

Ticker

6/recent/ticker-posts

MCQ based on array and string

1.

      What is right way to Initialize array?

ans:- A


2.
What will be the output of the program ?
#include<stdio.h>
void main()
{
    int a[5] = {5, 1, 15, 20, 25};
    int i, j, m;
    i = ++a[1];
    j = a[1]++;
    m = a[i++];
    printf("%d, %d, %d", i, j, m);
}



ans:- A


3.
What will be the output of following program code?
#include <stdio.h>
int main(void)
{
    char p;
    char buf[10] = {1, 2, 3, 4, 5, 6, 9, 8};
    p = (buf + 1)[5];
    printf("%d", p);
    return 0;
}

ans:- C


4.
An array elements are always stored in ________ memory locations.

ans:- A


5.
Let x be an array. Which of the following operations are illegal?
I.   ++x
II. x+1
III. x++
IV. x*2

ans:- D


6.
What will be printed after execution of the following code?
void main()
{
      int arr[10] = {1,2,3,4,5};
      printf("%d", arr[5]);
}


ans:- D


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

ans:- B


8.
Array passed as an argument to a function is interpreted as

ans:-C


9.
What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?
#include
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);
}

ams:- C


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

ans:- C


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

ans:- B


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


ans:-D


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

ans:- C


14.
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)));
}



















ans:-A


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


ans:- D


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

ans:- D


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

ans:- A


18.
What will be the correct output of the following program?
#include<string.h>
void main()
{
   char str[] = "C EXAMINATION", rev[17];
   int i = strlen(str), j=0;
   for( ; i>=0; rev[j++] = str[i--])
   rev[j] =  str[j] ;
   puts(rev);
}


ans:- D


19.
String concatenation means -

ans:- A


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

ans:- A

Post a Comment

0 Comments