Which of these is a correct way to declare a string in C?
A
string name;
B
char name[20];
Correct answer
C
str name;
D
name string;
Correct answer
B. char name[20];
11 views
⚔️
Challenge a friend on Computer Science FBISE Class 10
Same MCQs, timed, live leaderboard. Send the link on WhatsApp – no sign-up needed.
Create challenge
Explanation
char name[20]; declares a character array that can hold a string of up to 19 characters plus the null terminator. Strings in C are arrays of characters ending with '\0'.
Reference
Asked in: Matric,FBISE
Doubts & discussionNot sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ
‹ Previous MCQ The output of the following loop is: for(int i=0; i<3; i++) printf("%d", i); Next MCQ › Data visualisation is: