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 the proper way of these job Tell me about there full work

0 Answers   EDS,


there is two conditions , 1. while using for loop for printing 1 to 50 no's simulteneous 2. while using printf functios for printing 1 to 50 no's simulteneous with or without using variables who will take more time for compiling and execution? explain in details with reason?

1 Answers  


what is a static function

10 Answers   Satyam,


Explain the difference between exit() and _exit() function?

0 Answers  


main() { int x=10,y=15; x=x++; y=++y; printf("%d %d\n",x,y); } output??

19 Answers   EBS, Ramco, Sangwin, TCS,






how can f be used for both float and double arguments in printf? Are not they different types?

0 Answers  


I have a function which accepts, and is supposed to initialize,a pointer, but the pointer in the caller remains unchanged.

1 Answers  


related to rdbms query .

2 Answers  


What are the 5 data types?

0 Answers  


void main() { int a=1; printf("%d %d %d",a,++a,a++); } the output is supposed to be 1 2 2....but it is 3 3 1 this is due to calling conventions of C. if anyone can explain me how it happens?

7 Answers  


What are formal parameters?

0 Answers  


How can I remove the leading spaces from a string?

0 Answers  


Categories