WAP to find the sum of the reciprocal of a set of integer numbers to be feed from the keyboard . however reciprocal of 0 is not defined and should be ignored...


void main()
{
float i,no,rev,sum;
clrscr();
for(i=1; i<=5;i++)
{
printf("Enter the number");
scanf("%f", &no);
if(no==0)
continue;
else
rev=1/no;
printf("\n%f",rev);
sum=sum+rev;
}
printf("\n\nsum of reciprocal=%f",sum);
getch();
}

No comments:

Post a Comment