#include<stdio.h>
#include<string.h>
int main()
{
int i,c1=0,c2=0,c3=0;
char c[50];
printf("enter your input: \n");
gets(c);
for(i=0;i<strlen(c);i++)
{
if(c[i]==' ')
c1++;
else if(c[i]!=' ')
c2++;
}
printf("number of words:%d\n",c1+1);
printf("number of characters:%d\n",c2);
}
#include<stdio.h>
#include<string.h>
int main()
{
int i;
char c[50],c1=0,c2=0;
printf("enter your input: \n");
gets(c);
for(i=0;i<strlen(c);i++)
{
if(c[i]>='a' && c[i]<='z')
{
c1++;
}
else if(c[i]>='A' && c[i]<='Z')
{
c2++;
}
}
printf("lower case characters: %d\n",c1);
printf("lower case characters: %d\n",c2);
}
#include<stdio.h>
#include<string.h>
int main()
{
char c[50],x[40];
char *p;
printf("enter your input: \n");
gets(c);
printf("enter your string you wish to search: \n");
gets(x);
p=strstr(c,x);
if(p)
{
printf("'%s' is found inside of '%s'",x,c);
}
else
{
printf("not found!");
}
}
#include<stdio.h>
#include<string.h>
int main()
{
int i,c1=0,c2=0,c3=0;
char c[50];
printf("enter your input: \n");
gets(c);
for(i=0;i<strlen(c);i++)
{
if(c[i]==' ')
c1++;
else if(c[i]=='\t')
c2++;
else if(c[i]=='\n')
c3++;
}
printf("number of spaces: %d\n",c1);
printf("number of tabs: %d\n",c2);
printf("number of new lines: %d\n",c3);
}
#include<stdio.h>
#include<string.h>
int main()
{
int i,y;
char c[50];
char x[50];
printf("enter first string: \n");
gets(c);
printf("enter second string: \n");
gets(x);
if(strlen(c)>strlen(x))
{
printf("'%s' is bigger\n",c);
}
else if(strlen(c)==strlen(x))
{
printf("equal\n");
}
else
{
printf("'%s' is bigger",x);
}
}
#include<stdio.h>
#include<string.h>
int main()
{
int i;
char c[50],c1=0,c2=0,c3=0,c4=0;
printf("enter your input: \n");
gets(c);
for(i=0;i<strlen(c);i++)
{
if(c[i]=='a' ||c[i]=='e' ||c[i]=='i' ||c[i]=='o' ||c[i]=='u' ||c[i]=='A' ||c[i]=='E' ||c[i]=='I' ||c[i]=='O' ||c[i]=='U' )
{
c1++;
}
else if((c[i]>='A' && c[i]<='Z') || (c[i]>='a' && c[i]<='z') )
{
c2++;
}
else if(c[i]>='0' && c[i]<='9')
{
c3++;
}
else if(c[i]!=' a')
{
c4++;
}
}
printf("vowels %d\n",c1);
printf("consonants %d\n",c2);
printf("digits %d\n",c3);
printf("special symbol %d\n",c4);
}
#include<stdio.h>
#include<string.h>
int main()
{
int i;
char c[50];
inty x;
printf("enter your input: \n");
gets(c);
x=strlen(c);
printf("%d is the length of string",x);
}
#include<stdio.h>
#include<string.h>
int main()
{
int i;
char c[50];
printf("enter your input: \n");
gets(c);
c[0]=c[0]-32;
for(i=0;i<strlen(c);i++)
{
if(c[i-1]==' ')
c[i]=c[i]-32;
}
puts(c);
}
#include<stdio.h>
#include<string.h>
int main()
{
int i;
char c[50],c1=0;
char x;
printf("enter your input: \n");
gets(c);
printf("enter character you wish to search: \n");
scanf("%c",&x);
for(i=0;i<strlen(c);i++)
{
if(c[i]==x )
{
c1++;
}
}
if(c1!=0)
{
printf("%c is found!",x);
}
else
printf("%c NOT found",x);
}
#include<stdio.h>
#include<string.h>
int main()
{
int i;
char c[50],x[40];
char *p;
printf("enter your input: \n");
gets(c);
printf("enter your string: \n");
gets(x);
p=strstr(c,x);
if(p)
{
printf(" '%s' is found inside of '%s' and location is '%s' ",x,c,p);
}
else
{
printf("0");
}
}
#include<stdio.h>
#include<string.h>
int main()
{
int i,x,y;
char c[50];
printf("enter your input: \n");
gets(c);
printf("you are requested to enter range you wish to extract: \n");
printf("enter starting position: \n");
scanf("%d",&x);
printf("enter ending position: \n");
scanf("%d",&y);
for (i=x;i<=y;i++)
{
printf("%c", c[i]);
}
}
#include<stdio.h>
#include<string.h>
int main()
{
int i;
char c[50];
printf("enter the string you wish to reverse: \n");
gets(c);
strrev(c);
puts(c);
}
#include<stdio.h>
#include<string.h>
int main()
{
int i
char c[50];
printf("enter your input: \n");
gets(c);
for(i=0;i<strlen(c);i++)
{
if(c[i]>='a' && c[i]<='z')
c[i]=c[i]-32;
else if(c[i]>='A' && c[i]<='Z')
c[i]=c[i]+32;
}
puts(c);
}
#include<stdio.h>
#include<string.h>
int main()
{
int i,c1=0;
char c[50];
char x;
printf("enter your input: \n");
gets(c);
printf("you are requested to enter character you wish to search times of occuring: \n");
scanf("%c",&x);
for(i=0;i<=strlen(c);i++)
{
if(c[i]==x)
{
c1++;
}
}
if(c1!=0)
{
printf("%d",c1);
}
else
{
printf("not found!");
}
}