ACP_U1p8.c

#include<stdio.h> #include<conio.h> #include<stdlib.h> #define MAX 50 struct state_det { char name[50]; long population; int literacy; long income; }s[MAX]; void main() { int n,i,max_lit = 0, max_income = 0; int t, p; clrscr(); printf("enter number of states\n"); scanf("%d",&n); for(i = 0; i < n; i++) { printf("enter the name of the state %d\n",i); scanf("%s",&s[i].name); printf("enter the population of the state %d\n",i); scanf("%ld",&s[i].population); printf("enter the literacy rate of the state %d\n",i); scanf("%d",&s[i].literacy); printf("enter the average income of the state %d\n",i); scanf("%ld",&s[i].income); } max_lit = s[0].literacy; max_income = s[0].income; for(i = 1; i < n; i++) { if(max_lit < s[i].literacy) { max_lit = s[i].literacy; t = i; } if(max_income < s[i].income) { max_income = s[i].income; p = i; } } printf("\nthe state with highest literacy is %s and rate = %d\n",s[t].name, s[t].literacy); printf("\nthe state with highest income is %s and rate = %ld\n",s[p].name, s[p].income); getch(); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.