.//WAP To Calculate The Number of Character in A String
.//WAP To Calculate The Number of Character in A String
#include<stdio.h>
#include<stdio.h>
void main()
{ int i,count;
char a[20];
clrscr();
i=0;
count=0;
gets(a);
while(a[i]!='\0')
{ count++;
i++;
getch();
}
28.//WAP to find number of characters and white
spaces in a string.
#include<stdio.h>
#include<stdio.h>
void main()
{ int i,count,c;
char a[20];
clrscr();
i=0;
count=0;
c=0;
gets(a);
while(a[i]!='\0')
{ count++;
i++;
if(a[i]==' ')
c++;
}
printf("The number is %d",count);
getch();
}
29.//WAP to copy a string to another string.
#include<stdio.h>
#include<conio.h>
void main()
{ int i=0;
char a[20],b[30];
clrscr();
gets(a);
while(a[i]!='\0')
b[i]=a[i];
i++;
}b[i]='\0';
puts(b);
getch();
}
30.//WAP to concatenate.
#include<stdio.h>
#include<conio.h>
void main()
{ int i=0,j;
char a[20],b[30],c[55];
clrscr();
gets(a);
gets(b);
while(a[i]!='\0')
c[i]=a[i];
i++;
c[i]=' ';
for(j=0;b[j]!='\0';j++)
c[j+i+1]=b[j];
c[j+i+1]='\0';
getch();
}
31.//WAP to convert lower to upper case.
#include<stdio.h>
#include<stdio.h>
void main()
{ int i,count,c;
char string[20];
clrscr();
c=0;
gets(string);
while(string[c]!='\0')
{ if(string[c]>='a'&&string[c]<='z')
{ string[c]=string[c]-32;
c++;
getch();
}
32.//WAP to compare two strings.
#include<stdio.h>
#include<stdio.h>
void main()
{ int i,count,c,flag;
char a[20],b[20];
clrscr();
c=0;
gets(a);
gets(b);
while(a[c]==b[c])
{ if(a[c]=='\0'||b[c]=='\0')
break;
c++;
if(a[c]=='\0'&&b[c]=='\0')
flag=0;
else flag=1;
if(flag==0)
else
printf("Entered strings are not equal");
getch();
}
33.//WAP to Reverse a String...
#include<stdio.h>
#include<conio.h>
void main()
{
char str[20],rev[20];
int i=0,j=0;
printf("Enter Any String:- ");
scanf("%s",str);
while(str[i]!='\0')
{
i++;
}
i--;
while(i>=0)
{
rev[j]=str[i];
j++;
i--;
}
rev[j]='\0';
printf("Reverse Of Your String Is:- %s",rev);
getch();
}