0
string and char
What is the difference in using string and char data type
3 ответов
+ 3
Char:
1. A char holds a single character.
2. Char is a primitive type.
3. Elements in character array are stored contiguously in increasing in memory location.
Example: char[ ] a = {'a', 'p', 'p', 'l', 'e'};
String:
1. String holds lots of characters.
2. String is a reference type.
3. Strings can be stored in any manner in the memory.
Example: string a = "apple";
Hope it helps 😊
And yeah sorry for grammatical mistake.
0
I think this is explained in the course :)
have you done it?
0
in short: string is any combination of chars, but it is a string, which means it is treated as such.
1 + 1 #output 2
but
“1 + 1” #output 1 + 1
chars are always single characters and never a combination