C Programs on flow control statements (if, switch, loop, break and continue)-1

2015 & 2016 Batch Freshers Registration Link

Write a c program to print Hello world without using any semicolon.
main()
{
if(printf(“Hello World”))
{
}
}
C Program to Check Whether a Number is Even or Odd
main()
{
int num;
printf(“ Enter a number “);
scanf(“ %d ”,&num);
if((num%2)==0)
{
printf(“Even”);
}
else
{
printf(“Odd);
}
}

C Program to Find the Largest Number between two Numbers
main()
{
int num1,num2,large;
printf(“ Enter two numbers “);
scanf(“ %d %d ”,&num1,&num2);
if(num1 > num2)
{
large=num1
}
else
{
large=num2;
}
printf( “Largest number is %d”,large);
}
C Program to Find the Smallest Number between two numbers
main()
{
int num1,num2,small;
printf(“ Enter two numbers “);
scanf(“ %d %d ”,&num1,&num2);
if(num1 < num2)
{
small=num1;
}
else
{
small=num2;
}
printf( “Smallest number is %d”,small);
}
C Program to Find the Largest Number among Three Numbers
main()
{
int num1,num2,num3,large;
printf(“ Enter three numbers “);
scanf(“ %d %d %d”,&num1,&num2,&num3);
if(num1 > num2 && num1 > num3)
{
large=num1;
}
else if(num2 > num1 && num2 > num3)
{
large=num2;
}
else
{
large=num3;
}
printf( “Largest number is %d”,large);
}
C Program to Find the Smallest Number among Three Numbers
main()
{
int num1,num2,num3,small;
printf(“ Enter three numbers “);
scanf(“ %d %d %d”,&num1,&num2,&num3);
if(num1 < num2 && num1 < num3)
{
small=num1;
}
else if(num2 < num1 && num2 < num3)
{
small=num2;
}
else
{
small=num3;
}
printf( “Smallest number is %d”,small);
}
C Program to Check Leap Year
main()
{
int year;
printf(“Enter year”);
scanf(“%d”,&year);
if(year%4==0 && (year % 100 !=0 || year % 400 ==0))
{
printf(“Leap year”);
}
else
{
printf(“not a leap year);
}
}