c string programs

      Comments Off on c string programs

c string programs

c string programs

c string programs is collection of string related programs like counting number of characters, counting number of upper case character and lower case character. in this collection i have also added few programs with functions and few without functions so you can learn logic also. Don’t forget to refer other C Fundamental programs and pattern programs before you learn this string programs.

Have you checked, C Series Tutorial?

c string programs Example 1

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in
//Find string lenght using strlen function from string.h in C Programming

#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
	clrscr();
	char ch[30]={0};

	printf("\n Now Enter Text : ");
	gets(ch);

	printf("\n\t\t *****: Detail Description :***** ");

	printf("\n Length of String is = %3d",strlen(ch));

	getch();
}

 

c string programs Example 2

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in
//Count number of words in string using C Programming

#include <stdio.h>
#include <conio.h>
#include <string.h>

void main()
{
	clrscr();
	int i,words=1;
	char ch[30]={0};

	printf("\n Now Enter Text : ");
	gets(ch);

	i=0;
	do
	{
		if(ch[i]==32)
			words=words+1;

		i++;
	}while(ch[i]!=NULL);


	printf("\n\t\t *****: Detail Description :***** ");

	printf("\n Number of Words in String is = %3d",words);

	getch();
}

 

c string programs Example 3

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in


#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
	clrscr();
	int i;
	char ch[30];

	printf("\n Enter Lower Case Character : ");
	gets(ch);


	printf("\n ********** : Upper Case Character :**********\n\n");

	i=0;
	do
	{
		if(ch[i]>=97)
			putchar(ch[i]-32);
		else //if(ch[i]>=65 || ch[i]>=90)
		{
			putchar(ch[i]);
//			printf("%c",ch[i]);
		}
		i++;
	}while(ch[i]!=NULL);

	getch();
}

 

 

 

c string programs Example 4

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in
//convert upper case character to lower case without function

#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
	clrscr();
	int i;
	char ch[30];

	printf("\n Enter Upper Case Character : ");
	gets(ch);


	printf("\n ********** : Lower Case Character :**********\n\n");

	i=0;
	do
	{
		if(ch[i]>=65 && ch[i]<=90)
			putchar(ch[i]+32);
		else if(ch[i]==32)
			putchar(ch[i]);
		else
			putchar(ch[i]);

		i++;
	}while(ch[i]!=NULL);

	getch();
}

 

c string programs Example 5

//Written by Adarsh Patel
//Downloaded from http://adarshspatel.in
//toggle character using c programming

#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
	clrscr();
	int i;
	char ch[30];

	printf("\n Enter String Character : ");
	gets(ch);


	printf("\n **********: Toggle Case Character :**********\n\n");

	i=0;
	do
	{
		if(ch[i]>=65 && ch[i]<=90)
			putchar(ch[i]+32);
		else if(ch[i]>=97 && ch[i]<=122)
			putchar(ch[i]-32);
		else
			putchar(ch[i]);

		i++;
	}while(ch[i]!=NULL);

	getch();
}

 

c string programs Download All Programs (14 Total)

[sociallocker]Download[/sociallocker]