6 6 votes What is the output of the code given below?#include<stdio.h> int main() { char name[] = "satellites"; int len; int size; len = strlen(name); size = sizeof(name); printf("%d", len * size); return 0; } $100$ $110$ $40$ $44$ Programming in C goclasses programming goclasses-cs-dpp goclasses-cs-dpp-day-29 goclasses-c-programming-practice-questions + – GO Classes 614 views answer comment Share Follow Print See 1 comment 1 1 comment reply JHighlight commented Aug 1, 2025 reply Follow flag Expression Meaning Resultsizeof(name) Number of bytes in the array 11strlen(name) Number of visible characters 10 2 2 replyShare Please log in or register to add a comment.
4 4 votes Answer: b) 110.The above char array name can be written as below:char[] name = {'s','a','t','e','T','l','i','t','e','s', '10' };strlen gives no of characters in a string without the null in the end $=10$.sizeof gives the no of characters(no of bytes specifically) in a string including the null at the end $=11$So $11^ * 10=110$. GO Classes answered Jun 28, 2025 • edited Jun 30, 2025 by GO Classes Support 1 flag: ✌ Edit necessary (Rajkumar Chaudhary) GO Classes comment Share Follow 0 reply Please log in or register to add a comment.
3 3 votes Answer is 110 Now notice that here in the char name[] = "satellites"; we didn’t defined the size of string / array of chars, so it automatically added the /0 char So Strlen gives size 10 (excluding null char) And sizeof gives size 11 (including null char) If it would have been char name[10] = "satellites"; then there is no space for null char so the Strlen can result in undefined behavior — it could return a huge value or cause a crash. Sizeof will simply return the size as 10 If it would have been char name[10] = "satellite"; then there is one space left as we have 9 char only so null char will automatically be added. Strlen = 9 Sizeof = 10 If it would have been char name[10] = "sat"; then there is one space left as we have 9 char only so null char will automatically be added at 4th position. Strlen = 3 Sizeof = 10 akhil1 answered Jun 29, 2025 akhil1 comment Share Follow See 1 comment 1 1 comment reply JHighlight commented Aug 1, 2025 reply Follow flag ✅ Why sizeof(name) returns 11:name is a local array of 11 charsEach char takes 1 byteSo sizeof(name) returns 11 0 0 replyShare Please log in or register to add a comment.