Replace The Letters of a Sentence
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
char kal[100],a,b;
cout<<"replace the letters of a sentence:"<<endl<<endl;
cout<<"sentence:";
gets(kal);
cout<<"letters are replaced:";
cin>>a;
cout<<"replacement letter:";
cin>>b;
cout<<"result:";
for(int i=0; i<=strlen(kal); i++)
{
if(kal[i]==a)
cout<<b;
else
cout<<kal[i];
}
getch();
}
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
char kal[100],a,b;
cout<<"replace the letters of a sentence:"<<endl<<endl;
cout<<"sentence:";
gets(kal);
cout<<"letters are replaced:";
cin>>a;
cout<<"replacement letter:";
cin>>b;
cout<<"result:";
for(int i=0; i<=strlen(kal); i++)
{
if(kal[i]==a)
cout<<b;
else
cout<<kal[i];
}
getch();
}
good luck with my friends :)
Tidak ada komentar:
Posting Komentar