Pages

Sunday, April 26, 2020

MCQs C String Set - 2 Answer

MCQs C String Set - 2 Answer



The _________ string function can be used to read multiple words from user.
A. getc()
B. gets()
C. getchar()
D. getche()
ANSWER: B. gets()

Which of the following string function can be used to copy n characters from one string to another string?
A. strncpy
B. strcat
C. strncat
D. strlen
ANSWER: A. strncpy

What will be the output of following C program?
#include<stdio.h>
#include<string.h>
int main(){
  char state[20]="Gujarat India";
  printf("%d", strlen(state));
  return 0;
}
A. 13
B. 14
C. 20
D. none of these
ANSWER: A. 13

What will be the output of following C program?
#include<stdio.h>
#include<string.h>
int main() {
    char fname[20] = "K";
    char sname[20] = "Patel";
    printf("%s\n", strcpy(strcat(fname, sname), sname));
    return 0;
}
A. K Patel
B. Patel
C. K
D. none of these
ANSWER: B. Patel

What will be the output of following C program?
#include<stdio.h>
#include<string.h>
int main(){
    char str1[30] = "C Programming";
    char str2[30] = "Top C Practicals";
    printf("%s", strncpy(str1, str2, 16));
    return 0;
}
A. Top C Practicals
B. C Programming Top C Practicals
C. C Programming Top
D. none of these
ANSWER: A. Top C Practicals

Back to Questions Bank >



No comments:

Post a Comment