mardi 26 mai 2020

Case 3: if n is multiple of both 3 and 5

I'm not able to find the write line for third case. I'm a beginner in programming world. Much appreciated if someone helped me with this Thanks in advance!

#include <stdio.h>
int main()
{
    int n;

    scanf("%d",&n);

    if(n%3==0) {
      printf("\n 1");}
    else if(n%5==0){
      printf("\n 2");}
    else if((n%3==0) && (n%5==0)){
      printf("\n 3");}
    else{
      printf("\n 4");
    }

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire