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
Do pointers take up memory?
What are the types of macro formats?
What is getche() function?
Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
What is the acronym for ansi?
What is the benefit of using an enum rather than a #define constant?
When should you not use a type cast?
What is unsigned int in c?
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?
Difference between linking and loading?
What is C language ?
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
How can I invoke another program or command and trap its output?
What is a nested formula?