write a program for egyptian fractions in c?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Do pointers take up memory?

657


What are the types of macro formats?

606


What is getche() function?

608


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

643


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

918






What is the acronym for ansi?

631


What is the benefit of using an enum rather than a #define constant?

658


When should you not use a type cast?

661


What is unsigned int in c?

557


A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?

1511


Difference between linking and loading?

693


What is C language ?

1528


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

2401


How can I invoke another program or command and trap its output?

615


What is a nested formula?

605