Day 2 went very bad.
I started coding a weekly-average sleep time calculator. The user would input their sleep hour 7 times until the code exits the loop and calculate the average hour, and print it out. But I didn’t know how to use the loop correctly. Do I use
int hours[8];
and then use loops until all 7 values are filled? I could also make the users input 7 numbers and entering, but the spaces between the hours just made it look complicated. I myself would be confused typing the input. So I wanted to go a level up, but didn’t succeed.
I watched the loop video of my favorite programming YouTuber, but it wasn’t the right video.
still, Bro Code i saving my life with the 4-hour-long C Programming video.
And below is the “coding” I did on day2, I did poorly and deleted a bunch and was left with a trashy leftover.
#include<stdio.h>
int main(){
int hours[8];
int count = 0;
printf("==============================================\n");
printf("welcome to weekly average sleep time generator!\n");
printf("write down your sleep hours one by one. \n");
while(1){
scanf("%d", &hours);
if (hours == -1) break;
}
return 0;
}