Skip to content
Snippets Groups Projects
Commit d774c80d authored by Jakub Węgrowski's avatar Jakub Węgrowski
Browse files

Upload New File

parent a8069991
Branches
No related merge requests found
lab_4.c 0 → 100644
#include<stdio.h>
void Factorial();
void Fibonacci();
void Freefall();
int main () {
Factorial();
Fibonacci();
Freefall();
}
void Factorial (){
printf("Factorial:\n");
int Z;
printf("Give a whole number:\n");
scanf("%i",&Z);
double otp = 1;
for(int i = 1; i<=Z; i++){
otp *= i;
};
printf("Factorial of your number %.i is: %.f\n",Z ,otp);
};
void Fibonacci (){
printf("Fibonacci:\n");
int Y;
printf("Give a whole number:\n");
scanf("%i",&Y);
if(Y==1)
printf("0\n");
else if (Y==2)
printf("0,1\n");
else{
int otp_a = 0;
int otp_b = 1;
int temp;
for(int i = 1; i<=Y; i++){
printf("%i,",otp_a);
temp = otp_a;
otp_a += otp_b;
otp_b = temp;
};
printf("\n");
};
};
void Freefall(){
float H;
printf("Give a height:\n");
scanf("%f",&H);
float t = 0;
float hei = H;
printf("t: |h: \n");
while(hei >= 0){
printf("%.1f |%.2f\n",t ,hei);
t += 0.1;
hei = (H-(9.8*t*t)/2);
};
};
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment