0% found this document useful (0 votes)
12 views6 pages

Strings

Uploaded by

953622104017
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views6 pages

Strings

Uploaded by

953622104017
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

STRING REVERSE

#include <stdio.h>

#include<string.h>

int main()

char str1[10];

char rev[10];

gets(str1);

int i,j,k;

for(i=0;str1[i]!='\0';i++);

for(int k=i-1;k>=0;k--)

rev[j]=str1[k];

j++;

puts(rev);

2) Concat
#include <stdio.h>
#include<string.h>

int main()
{
char str1[10];
char str2[10];

gets(str1);
gets(str2);
int i,j;
for(i=0;str1[i]!='\0';i++);
{
for( j=0;str2[j]!='\0';j++,i++)
{
str1[i]=str2[j];
}
}

puts(str1);
}

3)REMOVE SPACE
// Online C compiler to run C program online
#include <stdio.h>

int main() {
char str1[10];
char str2[10];
gets(str1);
int i;
int c=0;
for(i=0;str1[i]!='\0';i++)
{
if(str1[i]!=' ')
{
str2[c]=str1[i];
c++;
}

}
str2[c]='\0'; // NOT PRINTING @
printf(str2);
}

4)VOWELS
#include <stdio.h>===
int main() {
char str[10];
gets(str);
int count=0;
for(int i=0;str[i]!='\0';i++)
if(str[i]=='a'|| str[i]=='e'|| str[i]=='i'|| str[i]=='o' || str[i]=='u' ||str[i]=='A' ||
str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U')
{
count++;
}

printf("%d",count);
}

5)space count
#include <stdio.h>
int main() {
char str[10];
gets(str);
int count=1;
for(int i=0;str[i]!='\0';i++)
{
if(str[i]==' ')
{
count++;
}
}
printf("%d",count);
}
Vowels
#include <stdio.h>

int main() {
char str[10];
gets(str);

for(int i=0;str[i]!='\0';i++)
{
if((str[i]>='a'&& str[i]<='z') || (str[i]>='A'&& str[i]<='Z' ))
{
printf("Alphapet");
}
else if (str[i]>='0' && str[i]<='9')
{
printf("number");
}
else
{
printf("special");
}
}

You might also like