in Programming in C recategorized by
1,756 views
2 votes
2 votes

Which of the following is illegal declaration in $C$ language?

  1. char*str ="Raj is a Research scholar";
    
  2. char str[25] ="Raj is a Research scholar";
    
  3. char str[40] ="Raj is a Research scholar";
    
  4. char[]str ="Raj is a Research scholar";

     

in Programming in C recategorized by
by
1.8k views

2 Answers

2 votes
2 votes

Ans initialization  of variable in Option D not valid

Character array/ string initialization:
char variable_name[]= "India";   
OR
char variable_name[10]= "India"; 

option B,D let str[25} an char array and starting address of array is 1000

R a j   i s   a   r e a r c h   s c h o l a r /0 /0

in Option A  str is char pointer which pointing or store starting address of char array

str

1000

 

4 Comments

whats the difference between options B and C?
0
0
@gatecse only the size of array is different (25 vs 40).
0
0
There is a spelling mistake in the answer. If corrected we can see that the given string does not fit in 25 characters or does it?
0
0
The compiler will not throw any error or warning, but since there is no space left for ‘\0’, you’ll see some garbage value after “scholar”.
1
1
0 votes
0 votes
corect option is d

char[]str ="Raj is a Research scholar";it is not a valid declaration in c language .
by
Answer:

Related questions