0 votes

#include <stdio.h>

int check_div(int n)

{

if(n%2==0)

{

if(n%3==0)

{

printf("Divisible by 2 and 3 both\n");

return 1;

}

printf("Divisible by 2 only\n");

return 2;

}

if(n%3==0)

{

printf("Divisible by 3 only\n");

return 3;

}

printf("Neither Divisible by 2 nor 3\n");

return 0;

}

int main()

{

int n;

printf("Enter the number\n");

scanf("%d",&n);

check_div(n);

return 0;

}

int check_div(int n)

{

if(n%2==0)

{

if(n%3==0)

{

printf("Divisible by 2 and 3 both\n");

return 1;

}

printf("Divisible by 2 only\n");

return 2;

}

if(n%3==0)

{

printf("Divisible by 3 only\n");

return 3;

}

printf("Neither Divisible by 2 nor 3\n");

return 0;

}

int main()

{

int n;

printf("Enter the number\n");

scanf("%d",&n);

check_div(n);

return 0;

}

0 votes

#include<stdio.h>

int main(){

int a;

scanf("%d",&a);

if(a%6==0)

printf("divisible by both 2 and 3");

else if(a%2==0)

printf("divisible by 2");

else if (a%3==0)

printf("divisible by 3");

else

printf("divisible by neither 2 nor 3");

return 0;

}

int main(){

int a;

scanf("%d",&a);

if(a%6==0)

printf("divisible by both 2 and 3");

else if(a%2==0)

printf("divisible by 2");

else if (a%3==0)

printf("divisible by 3");

else

printf("divisible by neither 2 nor 3");

return 0;

}

...