5_1.c
Write a program to count total words in text.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100],i;
int count=1;
clrscr();
printf("Enter the text\n");
gets(a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]==' ')
{
count++;
}
}
printf("The totalword ina text is=%d",count);
getch();
}
5_2.c
Find length of string using strlen( ) function,
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100];
int i;
clrscr();
printf("Enter the text\n");
gets(a);
i=strlen(a);
printf("%d",i);
getch();
}
5_3.c
Write a program to copy one string to another string.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100],b[100];
clrscr();
printf("Enter first string\n");
gets(a);
printf("Enter Second string\n");
gets(b);
strcpy(a,b);
puts(a);
getch();
}
5_4.c
Write a program to join two strings.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100],b[100],i;
clrscr();
printf("Enter first string\n");
gets(a);
printf("Enter Second string\n");
gets(b);
strcat(a,b);
printf("Joind String is=\n");
puts(a);
getch();
}
5_5.c
Write a program convert character into TOggLe character.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[100];
int i;
clrscr();
printf("Enter the string\n ");
gets(str);
for(i=0;str[i]!='\0';i++)
{
if(str[i]>='A'&&str[i]<='Z'&&str[i]!=' ')
{
str[i]=str[i]+32;
}
else if(str[i]>='a'&&str[i]<='z'&&str[i]!=' ')
{
str[i]=str[i]-32;
}
}
printf("\n\nThe Toggle Character is=\n");
puts(str);
getch();
}
5_6.c
Find given string is palingrom or not using string library function.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100],b[100],i;
clrscr();
printf("Enter the text\n");
gets(a);
strcpy(b,a);
strrev(b);
printf("\nRevers String is\n");
puts(b);
i=strcmp(a,b);
if(i==0)
{
printf("\n\nString is Palingrol");
}
else
{
printf("\n\nString is not a Palinrol");
}
getch();
}
Write a program to count total words in text.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100],i;
int count=1;
clrscr();
printf("Enter the text\n");
gets(a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]==' ')
{
count++;
}
}
printf("The totalword ina text is=%d",count);
getch();
}
5_2.c
Find length of string using strlen( ) function,
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100];
int i;
clrscr();
printf("Enter the text\n");
gets(a);
i=strlen(a);
printf("%d",i);
getch();
}
5_3.c
Write a program to copy one string to another string.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100],b[100];
clrscr();
printf("Enter first string\n");
gets(a);
printf("Enter Second string\n");
gets(b);
strcpy(a,b);
puts(a);
getch();
}
5_4.c
Write a program to join two strings.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100],b[100],i;
clrscr();
printf("Enter first string\n");
gets(a);
printf("Enter Second string\n");
gets(b);
strcat(a,b);
printf("Joind String is=\n");
puts(a);
getch();
}
5_5.c
Write a program convert character into TOggLe character.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[100];
int i;
clrscr();
printf("Enter the string\n ");
gets(str);
for(i=0;str[i]!='\0';i++)
{
if(str[i]>='A'&&str[i]<='Z'&&str[i]!=' ')
{
str[i]=str[i]+32;
}
else if(str[i]>='a'&&str[i]<='z'&&str[i]!=' ')
{
str[i]=str[i]-32;
}
}
printf("\n\nThe Toggle Character is=\n");
puts(str);
getch();
}
5_6.c
Find given string is palingrom or not using string library function.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100],b[100],i;
clrscr();
printf("Enter the text\n");
gets(a);
strcpy(b,a);
strrev(b);
printf("\nRevers String is\n");
puts(b);
i=strcmp(a,b);
if(i==0)
{
printf("\n\nString is Palingrol");
}
else
{
printf("\n\nString is not a Palinrol");
}
getch();
}
No comments:
Post a Comment