0

Can anyone pls explain the use of string, char ,and bool

3rd Oct 2016, 5:04 PM
ryan simethy
ryan simethy - avatar
7 Antworten
+ 5
string char and bool are 3 data type of variable. bool use less memory space than other and have 2 only state true and false, char use only 1 byte and the max lenght is 1 character string is an array of char so it takes as much space as the character contained. ex. string dog="mark"; use 4 char so it takes 1*4byte of space. you can use any type you want in your program but to write better code it's essential to reduce the space of the variable used as much as possible. ex. if you can solve a situation with a bool variable is better than a string. because your code can be putted inside a loop in another loop so your 4 character string become 4 byte *100*100= 40.000 byte vs 10.000 it doesn't seem much but if you think this on a large scale can be catastrophic for a big project :) Sorry for my bad english as you probably understand is not my main language :)
3rd Oct 2016, 5:38 PM
Ernesto Salvetti
Ernesto Salvetti - avatar
+ 1
String use double quotation "C" (Number,characters,symbols) and it's a part of standard library <string> Characters use a single quotation ' C ' (single letter,symbols) and holds a 1-byte integer Booleans we use bool and hold two value true and false
6th Oct 2016, 6:22 PM
Mohammed Ali
Mohammed Ali - avatar
0
char is used for storing character data,bool for data storage for lower decimal values like eg:0.053664
3rd Oct 2016, 5:25 PM
Manisha Patil
Manisha Patil - avatar
0
String treats the input as letters. Character refers to a single letter within a string (words). Boolean is either a True or False value.
14th Oct 2016, 11:06 PM
Sandra Setti
Sandra Setti - avatar
0
String is for letter and words!
14th Oct 2016, 11:26 PM
Sandra Setti
Sandra Setti - avatar
- 1
What is character data? What is string?
3rd Oct 2016, 5:27 PM
ryan simethy
ryan simethy - avatar
- 5
string is probably for numbers
3rd Oct 2016, 5:29 PM
Manisha Patil
Manisha Patil - avatar