In: Electrical Engineering
Write a program that asks the user to enter an array of 8 characters then you have to check if characters ‘b’ or ‘a’ appears within the characters and replace them with ‘B’ or ‘A’. For example you enter “a m a l a a b d” The output should be “A m A l A A B d”
The C Code is:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char inp[8],oup[8];
int i;
printf("Enter the Input String=>");
gets(inp);
for(i=0;i<=7;i++)
{
if(inp[i]=='a')
{
oup[i]='A';
}
else if(inp[i]=='b')
{
oup[i]='B';
}
else
{
oup[i]=inp[i];
}
}
oup[i]='\0';
printf("The Modified String is=>%s",oup);
getch();
}
Output: