Write a program that, given the integer n=13251, displays the value:
0 if n is not divisible by 2 or by 3
1 if n is divisible by 2 and not by 3
2 if n is divisible by 3 and not by 2
3 if n is divisible by 2 and by 3


Difficulty level
This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>
void main()
{
	int n,i,j,k;
	n=13251;
	i=n%2; 
	j=n%3;
	if(i!=0 && j!=0) 
		k=0;
	else 
		if(i==0 && j!=0) 
			k=1;
		else 
			if(i!=0 && j==0) 
				k=2;
			else 
				k=3;
	printf("%d\n",k);
	getch();
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Variable static implementation of a queue - version 1