1: #include<stdio.h>
2: #include<conio.h>
3: void main()
4: {
5: int n;
6: int i=1;
7: float sum=0.0;
8: do
9: {
10: printf("Enter the num %d:\n",i);
11: scanf("%d",&n);
12: if(n==0)
13: {
14: printf("reciprocal of the num is not defined\n");
15: continue;
16: }
17: sum+=1.0/(float)n;
18: i++;
19: }while(i<=5);
20: printf("Sum of the reciprocal is %f\n",sum);
21: getch();
22: }
No comments:
Post a Comment