Computer Science, asked by jikki6487, 11 months ago

What will be the size of the following constants : "\a". "\a", "Manoj\’s", ‘\", "XY\ YZ"

Answers

Answered by BrainlyYoda
11

Answer:

‘\a’ => Size is 1

Reason=> It is enclosed in single quotes having string literal and there is one character only in it so, it's size will be 1

“\a” => Size is 1

Reason=> Between double quotes there is only one character so, it's size will be 1

“Manoj\’s” => Size is 7

Reason=> Between double quotes there are 7 characters and is also a string.

“\” => Size is 1

Reason=> Between double quotes there contains one character and it is a character constant too.      

"XY\ YZ" => Size is 4

Reason=> It is a multiline string which create YZ” with \ in the basic string.

The \ add a new line in string.

Answered by mad210203
1

Sizes are 2, 10, 2, 6.

Explanation:

We can find size of the strings with the help of a program.

Let string 1 is \a, string 2 is Manoj\’s, string 3 is \ ,string 4 is XY\ YZ.

Program:

#include <stdio.h>

int main()

{

 char string_1[]="\a";

 char string_2[]="Manoj\’s";

 char string_3[]="\ ";

 char string_4[]="XY\ YZ";

printf("Size of string 1 is: %d\n",sizeof(string_1));

printf("Size of string 2 is: %d\n",sizeof(string_2));

printf("Size of string 3 is: %d\n",sizeof(string_3));

printf("Size of string 4 is: %d\n",sizeof(string_4));

}

Refer the attached image for the output.

Attachments:
Similar questions