Skip to content

Instantly share code, notes, and snippets.

@metrafonic
Created September 17, 2014 09:03
Show Gist options
  • Save metrafonic/3db8d73ba4ac66c8e7f6 to your computer and use it in GitHub Desktop.
Save metrafonic/3db8d73ba4ac66c8e7f6 to your computer and use it in GitHub Desktop.
Oppgave3
#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