write a program for egyptian fractions in c?



write a program for egyptian fractions in c?..

Answer / himaja

egyptian fraction is of the series eg 1/2+1/3=5/6.
#include<stdio.h>
#include<conio.h>
main()
{
int n,i=2,sum=0;
float m=0;
scanf("%d",&n);
for(i=0;i<=n;i++)
{
m = float(1/i);
sum=sum+m;
}
printf("%d",sum);
getch();

}

Is This Answer Correct ?    7 Yes 8 No

Post New Answer

More C Interview Questions

What is static identifier?

0 Answers   TCS,


Write a program to check prime number in c programming?

0 Answers  


why we use "include" word before calling the header file. is there any special name for that include??????

1 Answers   TCS,


main() { static char *s[]={"black","white","yellow","voilet"}; char **ptr[]={s+3,s+2,s+1,s}, ***p; p=ptr; **++p; printf("%s",*--*++p+3); }

1 Answers  


array contains zeros and ones as elements.we need to bring zeros one side and one other side in single parse. ex:a[]={0,0,1,0,1,1,0,0} o/p={0,0,0,0,0,1,1,1}

12 Answers   Google, Motorola,


How do I copy files?

0 Answers  


What is static memory allocation?

0 Answers  


what defference between c and c++ ?

6 Answers  


What are the uses of a pointer?

0 Answers  


How to avoid buffer overflow?

1 Answers  


What is meant by type specifiers?

0 Answers  


find the output of the following program main() { int x=5, *p; p=&x; printf("%d",++*p); }

10 Answers   Amdocs, TCS,


Categories