I am having problem with getting input for floating point under an structure array.The code is below:
#include<conio.h>
#include<stdio.h>
struct census
{
char city[20];
long int pop;
float lt;
};
int main()
{
struct census ct[5];
int i;
clrscr();
printf("Give details for 5 cities:");
for(i=0;i<5;i++)
{
printf("Cities(%d):\n",i+1);
printf("Name:");
scanf("%s",ct[i].city);
printf("Population:");
scanf("%ld",&ct[i].pop);
printf("Literacy:");
scanf("%f",&ct[i].lt);
}
clrscr();
for(i=0;i<5;i++)
{
printf("Cities(%d):\n",i+1);
printf("\nName:%s",ct[i].city);
printf("\nPopulation:%ld",ct[i].pop);
printf("\nLiteracy:%f",ct[i].lt);
}
getch();
return 0;
}
Here i am having problem getting the value for lt.can anyone tell me waht is the probelm?

New Topic/Question
Reply



MultiQuote





|