write a C program to read the address of a person in a single line and display the address in each line based on the symbol ",".
input: department of computing systems,faculty of applied science.
output: department of computing systems,
faculty of applied science.
Answers
Program:
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char address[100];
printf("Enter the address : ");
fgets(address, sizeof(address), stdin);
for(int i = 0 ; i < strlen(address) ; i++)
{
if(address[i] != ',')
{
printf("%c" , address[i]);
}
else
{
printf("\n");
}
}
return 0;
}
Output:
Enter the address : department of computing systems,faculty of applied science.
department of computing systems
faculty of applied science.
Answer:
#include<stdio.h>
int main(){
char address[200];
printf("\nHi there!\n");
printf("Enter your address here:\n");
gets(address);
printf("\n\n");
for(int index=0; index < 200; ++index){
char letter = address[index];
printf("%c", letter);
if(letter ==','){
printf("\n");
}
if(letter =='.'){
break;
}
}
return 0;
}
Explanation: