Created
September 17, 2014 09:03
-
-
Save metrafonic/3db8d73ba4ac66c8e7f6 to your computer and use it in GitHub Desktop.
Oppgave3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <conio.h> | |
int main(){ | |
int c; | |
float i=10, fact=1; | |
float e=1; | |
double factone=1; | |
double eone=1; | |
printf("Utregning av e\n"); | |
printf("Jeg får 34 ledd med float\nTrykk en tast for aa vise resultatene...\n"); | |
getch(); | |
for (c = 1; c<=35; c++){ | |
fact = fact * c; | |
e=e+(float)1/fact; | |
printf("%i. +1/%f, %f\n",c, fact, e); | |
} | |
printf("\n\n Naa med double:\n Jeg faar 170 ledd\nTrykk en tast for aa vise resultatene\n"); | |
getch(); | |
for (c = 1; c<=172; c++){ | |
factone = factone * c; | |
eone=eone+(double)1/factone; | |
printf("%i. +1/%f, %f\n",c, factone, eone); | |
} | |
getch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment