#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct voter
{
int id, age;
char nm[20], add[50];
};
voter ward[20];
int main()
{
clrscr();
for(int i=0;i<2;i++)
{
cout<<”\n voter no.”<<i+1;
cout<<” \n enter id no.:”;
cin>>ward[i].id;
cout<<”\n Enter name:”;
gets(ward[i].nm);
cout<<”\n enter address:”;
gets(ward[i].add);
cout<<”\n Enter age”;
cin>> ward[i].age;
}
cout<<”\n voters with age more then 60 are:\n”;
for(i=0;i<20;i++)
{
if(ward[i].age>60)
{
cout<<”\n id no:”;
cout<<ward[i].id;
cout<<”\n name:”;
cout.write(ward[i].nm,20);
cout<<”\n”;
}
}
}
Advertisement
December 8, 2008 at 5:50 am
in da for loop i<2 has been used corect it to i<20…
given was done for a dry run….:)