Professional Documents
Culture Documents
Strings 1 Annotated
Strings 1 Annotated
Strings -1
Lecture- 17
Raghav Garg
What are strings "O
and Why are
they used?
strings are basically car arrays.
Char str)]=I'a'b','d'e',"0'3;
I
raghar garg
Declaration of Strings
and taking Input
strings; Whav"
S
(ins;
conts;
Indexing of W
characters in v
Strings ~
strings:"Raghar" stitatio
sC0] - 'R'
Ques : Input a string of length n and count all
the vowels in the given string.
int n;
cinn;
char strin];
for (int 0;
=
i<n; i+ +)
I ain str[i];
3
Updation of a
single character
in string
012345
cont<<str;
reverse
length
substring
inte
string
etc
aplusplus. can
<string_name>.size()
push_back() Vectors
&
pop-back (S
“+” operator
reverse()
string str: "abcdef";
reverse (str. begin(), str.end());
Ques : Input a string of even length and
reverse the first half of the string.
01234567
string s -"Abdefgh";length - n 8
=
S);
+
substr() "abc";
d
string =
substring? ↓
a, ab, abc, b, bc, c
Ques : Input a string of even length and return the
second half of that string using inbuilt substr
function
to_string() Important
1
integer
It converts integer to
string
int n 12345
=
Ques : Return the total number of digits in a
number without using any loop.
4
Summary:
1) strings "abod";push-back(), pop-backl
=
word
4) S: "abc", t "xyz"
=
S S +
= +
+ 5 abcxyz
=
Thank you!