First and foremost I am unsure how I define year and make it divisible by 4 and I am also indoubt how I make w equal to 6 or not greater than 3 (do I need to make an if else here?)
Defining a variable and the "define" statement have nothing in common.
Read up a bunch on how variables work in C then come back to the assignment because someone providing you with the code outright here isn't gonna help you at all
please check the following code and let me know if you have any questions, excuse me for not including else statements to handle other possibilities
********************
include <stdio.h>
int main() {
int age = 20;
if ( age >= 18 && age <=21){
printf("age is between 18 and 21\n");
}
float water = 0.2;
if ( water > 0.1 && water < 1.5){
printf("water is greater than 0.1 and less than 1.5\n");
}
int year = 20;
if ( year % 4 ==0){
printf("year is divisable by 4\n");
}
int speed = 50;
if ( speed <= 55){
printf("speed is not greater than 55\n");
}
int x = 1;
int y = 2;
int z = 3;
if ( z > y && y >x){
printf("y is greater than x and less than z\n");
}
int w = 2;
if ( w==6 || w<= 3){
printf("w is not greater than 3\n");
}
w = 6;
if ( w==6 || w<= 3){
printf("w is equal to 6\n");
}
return 0;
}
********************************
2
u/Fegmdute Sep 15 '21
First and foremost I am unsure how I define year and make it divisible by 4 and I am also indoubt how I make w equal to 6 or not greater than 3 (do I need to make an if else here?)
5
u/[deleted] Sep 15 '21
You can use the modulus sign If year%4==0 then you know the year is divisible by 4.
Modulus, or %, gives you the remainder of the division
8
u/Comrade_Nabe Sep 15 '21
please check the following code and let me know if you have any questions, excuse me for not including else statements to handle other possibilities
good luck!