You are on page 1of 2

#include<stdio.

h>
void main()
{
//Largest of three numbers
printf("Largest of three numbers program.\n\n");
int a , b , c;
printf("Enter values of 'a' , 'b' and 'c': ");
scanf("%i %i %i" , &a , &b , &c);
if(a > b)
{
if(a > c)
{
printf("Largest number is %i" , a);
}
else
{
printf("Largest number is %i" , c);
}
}
else if(a < b)
{
if(b > c)
{
printf("Largest number is %i" , b);
}
else
{
printf("Largest number is %i" , c);
}
}
}
void main()
{
//Odd or even
printf("\n\nOdd or even dedection.\n\n");
int a;
printf("Enter a number: ");
scanf("%i" , &a);
if(a%2 == 0)
{
printf("The given number is 'EVEN' , i.e. a = %i" , a);
}
else
{
printf("The given number is 'ODD' , i.e. a = %i" , a);
}
}
void main()
{
//Leap year
printf("\n\nLeap year dedection.\n\n");
int a;
printf("Enter the year: ");
scanf("%i" , &a);
if(a%4 == 0)
{
printf("The entered year is a leap year , i.e. %i" , a);
}
else
{
printf("The entered year is not a leap year , i.e. %i" , a);
}
}
void main()
{
//Prime number
printf("\n\nPrime number dedection.\n\n");
int a , c = 0;
printf("Enter a number: ");
scanf("%i" , &a);
char b[a];
if(a > 0)
{
for(int i = 2 ; i < a ; i++)
{
if(a%i == 0)
{
b[c] = i;
c = c + 1;
}
}
if(c == 0)
{
printf("The given number is zero , i.e. %i" , a);
}
else
{
printf("The given number , i.e. %i is not a prime number, it's
divisible by following %i numbers:" , a , c);
for(int k = 0 ; b[k] ; k++)
{
printf("\n%i" , b[k]);
}
}
}
else
{
printf("The given number is not a positive number , i.e. %i" , a);
}
}

You might also like