Skip to content

Commit 922bf3c

Browse files
authored
Add files via upload
1 parent 4349959 commit 922bf3c

7 files changed

+105
-0
lines changed

String/01 Length of string.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main ()
4+
{
5+
char A[]="Shivendra";
6+
int i;
7+
for (i=0;A[i]!='\0';i++)
8+
{
9+
10+
}
11+
cout<<"Length of string is "<<i;
12+
return 0;
13+
14+
}

String/02 Change the case.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main ()
4+
{
5+
char A[]="SHIVENDRA";
6+
int i;
7+
for (i=0;A[i]!='\0';i++)
8+
{
9+
A[i]=A[i]+32;
10+
}
11+
cout<<"Changing upper case to lower "<<endl<<A;
12+
return 0;
13+
}

String/03 lower to upper.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main ()
4+
{
5+
char A[]="shivendra";
6+
int i;
7+
for (i=0;A[i]!='\0';i++)
8+
{
9+
A[i]=A[i]-32;
10+
}
11+
cout << "Changing in upper case"<< endl<< A;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main ()
4+
{
5+
char A[]="ShIvEnDRa";
6+
int i;
7+
for (i=0;A[i]!='\0';i++)
8+
{
9+
if (A[i]>=65 && A[i]<90)
10+
A[i]+=32; // This is for changing lower case
11+
else if (A[i]>=97 && A[i]<=122)
12+
A[i]-=32; // This is for changing upper case
13+
}
14+
cout<<"Changing Upper to lower and lower to upper "<<endl<<A;
15+
return 0;
16+
}

String/05 Vowel & Counstant count.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main ()
4+
{
5+
char A[]="I Am From Darbhanga Bihar";
6+
int i,vcount=0,ccount=0;
7+
for (i=0;A[i]!='\0';i++)
8+
9+
if (A[i]=='a'|| A[i]=='e'|| A[i]=='i' || A[i]=='o' || A[i]=='u' || A[i]=='A' || A[i]=='E' || A[i]=='I'|| A[i]=='O'|| A[i]=='U' )
10+
vcount++;
11+
else if ((A[i]>=65 && A[i]<=90) || (A[i]>=97 && A[i]<=122))
12+
ccount++;
13+
cout<<"Vowel count is "<<vcount<<endl;
14+
cout<<"Counstant count is "<<ccount;
15+
return 0;
16+
17+
}

String/06 Word Count.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main()
4+
{
5+
char A[]="My name is Shivendra";
6+
int i,word=1;
7+
for (i=0;A[i]!='\0';i++)
8+
{
9+
if (A[i]==' '&& A[i-1]!=' ') // if whitespace encounter in string it will count word // 2nd cond if more then one whitespace btw 2 conseqitive word it will eliminate
10+
word++;
11+
}
12+
cout<<"Total word is "<<word;
13+
return 0;
14+
}

String/07 Reverse the string.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main ()
4+
{
5+
char A[]="python";
6+
char B[7];
7+
int i;
8+
for (i=0;A[i]!='\0';i++)
9+
{
10+
11+
}
12+
i=i-1;
13+
for (int j=0;i>=0;i--,j++)
14+
{
15+
B[j]=A[i];
16+
}
17+
B[i]='\0';
18+
cout<<"Reverse of the string is "<<endl<<B;
19+
}

0 commit comments

Comments
 (0)