//PROGRAM TO STORE VOWELS OF FILE STRING TO ANOTHER FILE VOWELS
//Downloaded from www.c4cprog.co.nr
#include<stdio.h>
void main()
{
char c;
FILE *f,*f1;
f=fopen("STRING","w");
clrscr();
printf("Enter String :\n ");
while(scanf("%c",&c)!=EOF)
putw(c,f);
fclose(f);
f=fopen("STRING","r");
f1=fopen("VOWELS","w");
while((c=getw(f))!=EOF)
if((c=='a')||(c=='e')||(c=='i')||(c=='o')||(c=='u')||(c=='A')||(c=='E')||(c=='I')||(c=='O')||(c=='U'))
putw(c,f1);
fclose(f);
fclose(f1);
f1=fopen("VOWELS","r");
printf("\nVOWELS : \n");
while((c=getw(f1))!=EOF)
printf(" %c",c);
getch();
}
/*
OUTPUT
Enter String :
Program To Store The Vowels In A Paragraph To A File, Is Successfully Executed
^Z
VOWELS :
o a o o e e o e I A a a a o A i e I u e u E e u e
*/
Programs Can Also Be Downloaded From The Folders Below....[Or Scroll Down]
Showing posts with label String. Show all posts
Showing posts with label String. Show all posts
Store Vowels from one File to another
Click Here To Download C File Of This Program
String Functions - Length, Concatenate, Reverse, Copy, Combine, Compare & Extract
Click Here To Download C File Of This Program
//PROGRAM TO ERFORM STRING FUNCTION - STRING LENGTH, COPY, CONCATENATE, REVERSE, COMBINE, EXTRACT & COMPARE
//Downloaded from www.c4cprog.co.nr
#include<conio.h>
void string_length()
{
int i=0;
char str[100];
gets(str);
printf("\n\nEnter The String : ");
gets(str);
while(str[i]!='\0')
i++;
printf("\n\nLENGTH Of The String is : %d Characters",i);
}
void string_concatenate()
{
int i=0,p=0;
char str1[100],str2[100];
gets(str1);
printf("\n\nEnter The String : ");
gets(str1);
printf("\nEnter The String B : ");
gets(str2);
while(str1[p]!='\0')
p++;
for(i=0;str2[i]!='\0';i++,p++)
str1[p]=str2[i];
printf("\n\nThe CONCATENATED String is : ");
for(i=0;i<p;i++)
printf("%c",str1[i]);
}
void string_reverse()
{
int i=0,p=0,q=0;
char str1[100],str2[100];
gets(str1);
printf("\n\nEnter The String : ");
gets(str1);
while(str1[p]!='\0')
p++;
for(i=p-1;i>=0;i--,q++)
str2[i]=str1[q];
printf("\n\nREVERSED String : ");
for(i=0;i<q;i++)
printf("%c",str2[i]);
}
void string_copy()
{
int i=0,p=0;
char str1[100],str2[100];
gets(str1);
printf("\n\nEnter The String : ");
gets(str1);
while(str1[p]!='\0')
p++;
for(i=0;i<p;i++)
str2[i]=str1[i];
printf("\n\nCOPIED String : ");
for(i=0;i<p;i++)
printf("%c",str2[i]);
}
void string_combine()
{
int i=0,p=0,j;
char str1[100],str2[100],str3[100];
gets(str1);
printf("\n\nEnter The String : ");
gets(str1);
printf("\nEnter The String B : ");
gets(str2);
while(str1[p]!='\0')
p++;
for(i=0;i<p;i++)
str3[i]=str1[i];
for(j=0;str2[j]!='\0';j++,i++)
str3[i]=str2[j];
printf("\n\nThe COMBINED String is : ");
for(j=0;j<i;j++)
printf("%c",str3[j]);
}
void string_compare()
{
int p=0,q=0,d=0,e=0,k=0,i,t;
char str1[100],str2[100];
gets(str1);
printf("\nEnter The String A : ");
gets(str1);
printf("\nEnter The String B : ");
gets(str2);
while(str1[p]!='\0')
p++;
while(str2[q]!='\0')
q++;
if(p>q)
t=p;
else
t=q;
for(i=0;i<t;i++,d=0,e=0)
{
d=str1[i];
e=str2[i];
if(d!=e)
{
k++;
printf("\n\nRESULT = %d | The Strings Are NOT EQUAL",d-e);
break;
}}
if(k==0)
printf("\n\nTHE STRINGS ARE EQUAL");
}
void string_extract()
{
int o,q,j,p=0,i,t;
char str[100],str1[100];
gets(str);
printf("\n\nEnter The String : ");
gets(str);
printf("\n\nEnter The Position From Which Extraction Is To Be Done : ");
scanf("%d",&o);
printf("\n\nEnter The Length Of The String To Be Extracted : ");
scanf("%d",&q);
while(str[p]!='\0')
p++;
if(p-o<q)
t=p-0;
else
t=q;
for(i=0;i<p;i++)
if(i==(o-1))
for(j=0;j<q;j++,i++)
str1[j]=str[i];
printf("\n\nThe EXTRACTED String is : ");
for(j=0;j<t;j++)
printf("%c",str1[j]);
}
void main()
{
int op;
char v;
do{
clrscr();
printf("\nOPTIONS :\n\t1.Length Of String\n\t2.Concatinating String\n\t3.Reversing String\n\t4.Copy String\n\t5.Combine Strings\n\t6.Comparing Strings\n\t7.Extracting String\n\n\nEnter Choice :");
scanf("%d",&op);
switch(op)
{
case 1:
string_length();
break;
case 2:
string_concatenate();
break;
case 3:
string_reverse();
break;
case 4:
string_copy();
break;
case 5:
string_combine();
break;
case 6:
string_compare();
break;
case 7:
string_extract();
break;
default:
printf("\n\nINVALID CHOICE !!!");
break;
}
printf("\n\n\n\nPress 'e' To EXIT & Any Other Key To Continue : ");
scanf(" %c",&v);
}while(v!='e');
}
/*
OUTPUT
OPTIONS :
1.Length Of String
2.Concatinating String
3.Reversing String
4.Copy String
5.Combine Strings
6.Comparing Strings
7.Extracting String
Enter Choice :1
Enter The String : Checking The Length
LENGTH Of The String is : 19 Characters
Press 'e' To EXIT & Any Other Key To Continue : c
OPTIONS :
1.Length Of String
2.Concatinating String
3.Reversing String
4.Copy String
5.Combine Strings
6.Comparing Strings
7.Extracting String
Enter Choice :2
Enter The String : Checking
Enter The String B : Concatination
The CONCATENATED String is : CheckingConcatination
Press 'e' To EXIT & Any Other Key To Continue : c
OPTIONS :
1.Length Of String
2.Concatinating String
3.Reversing String
4.Copy String
5.Combine Strings
6.Comparing Strings
7.Extracting String
Enter Choice :3
Enter The String : Checking String Reverse
REVERSED String : esreveR gnirtS gnikcehC
Press 'e' To EXIT & Any Other Key To Continue : c
OPTIONS :
1.Length Of String
2.Concatinating String
3.Reversing String
4.Copy String
5.Combine Strings
6.Comparing Strings
7.Extracting String
Enter Choice :4
Enter The String : Copying A String
COPIED String : Copying A String
Press 'e' To EXIT & Any Other Key To Continue : c
OPTIONS :
1.Length Of String
2.Concatinating String
3.Reversing String
4.Copy String
5.Combine Strings
6.Comparing Strings
7.Extracting String
Enter Choice :5
Enter The String : Testing
Enter The String B : For Combining Strings
The COMBINED String is : TestingFor Combining Strings
Press 'e' To EXIT & Any Other Key To Continue : c
OPTIONS :
1.Length Of String
2.Concatinating String
3.Reversing String
4.Copy String
5.Combine Strings
6.Comparing Strings
7.Extracting String
Enter Choice :6
Enter The String A : String Comparing
Enter The String B : Is Tested
RESULT = 10 | The Strings Are NOT EQUAL
Press 'e' To EXIT & Any Other Key To Continue : c
OPTIONS :
1.Length Of String
2.Concatinating String
3.Reversing String
4.Copy String
5.Combine Strings
6.Comparing Strings
7.Extracting String
Enter Choice :7
Enter The String : Sting Is To Be Extracted
Enter The Position From Which Extraction Is To Be Done : 2
Enter The Length Of The String To Be Extracted : 6
The EXTRACTED String is : ting I
Press 'e' To EXIT & Any Other Key To Continue : e
*/
String - Sort and Check for Palindrome
Click Here To Download C File Of This Program
//PROGRAM TO SORT GIVEN STRINGS & CHECK FOR PALINDROME
//Downloaded from www.c4cprog.co.nr
#include<conio.h>
#include<string.h>
void sort(char st[50][20],int n)
{ int i,j;
char k[50];
for(i=0;i<n;i++)
for(j=0;j<n-1;j++)
if(strcmp(st[j],st[j+1])>1)
{
strcpy(k,st[j]);
strcpy(st[j],st[j+1]);
strcpy(st[j+1],k);
}
for(i=0;i<n;i++)
{
printf("\nString %d :",i+1);
printf("%s",st[i]);
}
}
void palindrome(char st[50][20],int n)
{
int i,j,r=0;
char k[50];
for(i=0;i<n;i++)
{
strcpy(k,st[i]);
strrev(k);
if(strcmp(st[i],k)==0)
{
printf("\n\nString %d is Palindrome",i+1);
r++;
}}
if(r==0)
printf("\n\nNo Palindromes !!!");
}
void main()
{
int op,n,i;
char st[50][20],k[50],v;
do{
clrscr();
printf("\nEnter The no of Strings : ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nString %d :",i+1);
scanf("%s",&st[i]);
}
printf("\nOptions\n\n1.Sort String\n2.Check For Palindrome\n\nEnter Option :");
scanf("%d",&op);
switch(op)
{
case 1:
sort(st,n);
break;
case 2:
palindrome(st,n);
break;
default:
printf("\n\nWRONG CHOICE !!!");
break;
}
printf("\n\nPress 'e' To EXIT & Any Other Key To Continue : ");
scanf(" %c",&v);
}while(v!='e');
}
/*
OUTPUT
Enter The no of Strings : 3
String 1 :Testing
String 2 :The
String 3 :Program
Options
1.Sort String
2.Check For Palindrome
Enter Option :1
String 1 :Program
String 2 :Testing
String 3 :The
Press 'e' To EXIT & Any Other Key To Continue :c
Enter The no of Strings : 3
String 1 :MALAYALAM
String 2 :IS
String 3 :PALINDROME
Options
1.Sort String
2.Check For Palindrome
Enter Option :2
String 1 is Palindrome
Press 'e' To EXIT & Any Other Key To Continue : e
*/
Acronym Of String
Click Here To Download C File Of This Program
//PROGRAM TO FIND ACRONYM OF A STRING
//Downloaded from www.c4cprog.co.nr
#include<conio.h>
#include<string.h>
void main()
{
int k=1,i;
char st[100],st2[10];
clrscr();
printf("\n\nEnter The String : ");
gets(st);
st2[0]=toupper(st[0]);
for(i=1;i<strlen(st);i++)
if(st[i]==' ')
{
st2[k]=toupper(st[i+1]);
k++;
}
printf("\n\nThe ACRONYM Is : ");
for(i=0;i<k;i++)
printf("%c",st2[i]);
getch();
}
/*
OUTPUT
Enter The String : Testing The Program Of Acronym
The ACRONYM Is : TTPOA
*/
Subscribe to:
Posts (Atom)


