SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0;
char str[10],och,nch;
clrscr();
printf("Enter a string:");
scanf("%s",str);
flushall();
puts("Enter a char to be replace:");
scanf("%c",&och);
flushall();
puts("Enter new character:");
scanf("%c",&nch);
while(str[i]!='\0')
{
if(str[i]==och)
{
str[i]=nch;
}
i++;
}
printf("new string is:");
printf("%s",str);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0;
char str[10],och,nch;
clrscr();
printf("Enter a string:");
scanf("%s",str);
flushall();
puts("Enter a char to be replace:");
scanf("%c",&och);
flushall();
puts("Enter new character:");
scanf("%c",&nch);
while(str[i]!='\0')
{
if(str[i]==och)
{
str[i]=nch;
}
i++;
}
printf("new string is:");
printf("%s",str);
getch();
}
No comments :
Post a Comment