- #1
Vavotaj
- 14
- 0
#include <stdio.h>
#include <string.h>
double faktoriel (double y);
void main()
{
double x, fac;
char yes[5] ="yes";
char answer[5];
do
{
printf("Enter number:\n");
scanf("%f", &x);
while (50>x || x>100)
{
printf("Number doesn't match \n"); //50<x<100
printf("Enter number again:\n");
scanf("%f", &x);
}
fac = faktoriel (x);
}while(strcmp (yes, answer)!=0);
return;
}
double faktoriel (double y)
{
double i, factor;
for(i=y; i>1; i--)
{
factor*=i;
}
printf("%f", factor);
return factor;
}
----------------------------------------------------------------------------------------
There are proly many mistakes xD
#include <string.h>
double faktoriel (double y);
void main()
{
double x, fac;
char yes[5] ="yes";
char answer[5];
do
{
printf("Enter number:\n");
scanf("%f", &x);
while (50>x || x>100)
{
printf("Number doesn't match \n"); //50<x<100
printf("Enter number again:\n");
scanf("%f", &x);
}
fac = faktoriel (x);
}while(strcmp (yes, answer)!=0);
return;
}
double faktoriel (double y)
{
double i, factor;
for(i=y; i>1; i--)
{
factor*=i;
}
printf("%f", factor);
return factor;
}
----------------------------------------------------------------------------------------
There are proly many mistakes xD