How would I go about checking if a number entered by a user is evenly divisible by 2,3,4,5,7. If the value entered is evenly divisible I'd like the program to print out a statement for each number. If i used the % to check if the value is zero would that work?
#include<stdio.h>
int main() {
int number;
printf("Enter a number");
scanf("%d",&number);
if (number%2 == 0){
prinntf("%d is divisible by 2",number);
}
else if (number%3 ==0){
prinntf("%d is divisible by 3",number);
}
else if (number%4 == 0){
prinntf("%d is divisible by 4",number);
}
return 0;
}
This is what i wrote so far but I know there's a few errors.
Aucun commentaire:
Enregistrer un commentaire