C Programming String Multiple choice question

Exercise : - Multiple Choice Question On C Programming, MCQ C Programming String

This section contains a lot of c programming question and answer with explanation on the topic string. These question and answer are very much helpful for interview(campus interviews, walkin interviews, company interviews), competitive examination ,entrance test and placements. Each question having answer and explanation that would help you to understand easily. These question are designed from basic to advance level. So anyone can learn from here (beginner, fresher, engineering graduate, an experienced IT professional).

All the question of c programming are listed below on string along with detailed explanation / solution and answer.

1) What would be the output of the following C programs ?
                                                                          

#include <stdio.h> #define PRODUCT(x) ( x * x ) void main( ) { char c[2] = "B" ; printf ( "%c", c[0] ) ; printf ( "%s", c ) ; }

A. BB
B. B
C. Garbage B
D. Compilation Error

Answer:

BB

Option:

( A )


Explanation :

No explanations available for this question.


2) What would be the output of the following C programs ?
                                                                          

#include <stdio.h> int main() { char *ch = "pt"; char *ch1 = "pt"; if (strcmp(ch, ch1)) printf("equal"); else printf("unequal"); }

A. equal
B. unequal
C. Run Time Error
D. Compilation Error

Answer:

unequal

Option:

( B )


Explanation :

No explanations available for this question.


3) What would be the output of the following C programs ?
                                                                          

#include <stdio.h> void main( ) { char s[ ] = "learn C Programming" ; printf ( "\n%s", &s[2] ) ; }

A. learn C Programming
B. arn C Programming
C. Run Time Error
D. Compilation Error

Answer:

arn C Programming

Option:

( B )


Explanation :

No explanations available for this question.


4) What would be the output of the following C programs ?
                                                                          

#include<stdio.h> #include<string.h> void main() { char str1[20] = "Hello", str2[20] = " World"; printf("%s\n", strcpy(str2, strcat(str1, str2))); }

A. Hello
B. Hello World
C. Run Time Error
D. Compilation Error

Answer:

Hello World

Option:

( B )


Explanation :

No explanations available for this question.


5) What is the output of the following program ?
                                                                          

#include<stdio.h> void main( ) { printf ( 8 + "Good Morning " ) ; }

A. 8Good Morning
B. ning
C. Morning
D. Compilation Error

Answer:

ning

Option:

( B )


Explanation :

No explanations available for this question.