Monday, April 5, 2021

17.9. A file contains some country name and capital. Write a program that repeatedly read any country name and display capital until user enters the word "End",

#include<stdio.h> 
#include<conio.h>
#include<string.h>
struct tnt
{
char name[20];
long phone:
};
void main()
{
fp=fopen ("J114.in", "r"):
n=0
while (fscanf(fp, &s %s”,a[n].name,a[n].capital)! = EOF)
n++;
for (;;)
{
printf("\n country name: ")
Scanf ("%s", st);
if (strempi (st, "End") =0)
break:
for (i=0; i<n; i++)
if (atrcmpi (a [1].name, st) ==0)
printf("Capital: $s", a[i]).capital);
}
}

No comments:

Post a Comment