Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FizzBuzz, BMI, reverse string #37

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions November/Day 29/C/Body-Mass-Index.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>

float BodyMassIndex(float weight, int age, float height){
float mass = weight/10;
return mass / (height*height);
}

int main() {
float weight, height;
int age;
// person enters weight
printf("Weight(N): ");
scanf("%f", &weight);
//person enters age
printf("Age: ");
scanf("%d", &age);
//person enters height
printf("Height(m): ");
scanf("%f", &height);

float BMI = BodyMassIndex(weight, age, height);
printf("BMI: %0.1f kg per m squared", BMI);
}
28 changes: 28 additions & 0 deletions November/Day 29/C/Fizz-Buzz.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdio.h>

void fizzBuzz(int n){
for(int i = 1; i <= n; i++){

if(i>=5 && i%5==0 && i >= 3 && i%3 == 0){
printf("fizzbuzz\n");
}
else if(i >= 3 && i%3 == 0){

printf("fizz\n");

}else if(i>=5 && i%5==0) {
printf("buzz\n");
}

else{
printf("%d\n", i);
}

}
return;
}

int main() {

fizzBuzz(30);
}
33 changes: 33 additions & 0 deletions November/Day 29/C/Reverse-string.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <stdio.h>

// The numberOfLetters function, gets the number of characters the person has entered
// so that the reverse function can iterate through the loop

int numberOfLetters(char word[]){
int count = 0;
while(count>=0 ) {
count++;
if(word[count-1] == '\0') {
return count-1;
}

}
}



void reverse(char word[]){
int num = numberOfLetters(word);
for(int i=num; i>=0; i--){
printf("%c", word[i]);
}

printf("\n");
return;
}

int main() {

reverse("Greetings!");

}