Discussion
In C Programming, If we need to store word "INDIA" then syntax is as below -
Answer: A
Correct answer: char name[6] = {'I','N','D','I','A','\0'}
A C string is a character array ending in a terminating null, so “INDIA” needs six cells: five letters and '\0'. Single quotes make characters; double quotes would make five separate strings. And an array cannot be assigned to after declaration, so name = "INDIA"; is not valid either. (char name[6] = "INDIA"; would also work - the compiler supplies the null.)
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development