Friday, 26 June 2015



Aim - WAP To Find Smallest and Largest Among Four Numbers.

Code -

#include<stdio.h>

#include<conio.h>

void main ()

{

int a, b, c, d;

clrscr ();

printf ("Enter The Four Numbers Respectively : ");

scanf ("%d %d %d %d", &a, &b,&c, &d);

if (a>b && a>c && a>d)

printf ("%d Is The Largest Number\n", a);

else if (b>a && b>c && b>d)

printf ("%d Is The Largest Number\n", b);

else if (c>a && b<c && c>d)

printf ("%d Is The Largest Number\n", c);

else

printf ("%d Is The Largest Number\n", d);

if (a<b && a<c && a<d)

printf ("%d Is The Smallest Number\n", a);

else if (a>b && b<c && b<d)

printf ("%d Is The Smallest Number\n", b);

else if (c<b && a<c && c<d)

printf ("%d Is The Smallest Number\n", c);

else

printf ("%d Is The Smallest Number\n", d);

getch ();

}





OUTPUT

Enter The Four Numbers Respectively : 34 53 87 67

87 Is The Largest Number

34 Is The Smallest Number





















Aim – WAP To Reverse a 5-digit Number and Check Whether The Reversed And Original Numbers Are Equal

Code -



#include<stdio.h>

#include<conio.h>

void main ()

{

long int num, a, b, c, d, e, num1;

clrscr ();

printf ("Enter The 5 Digit Number : ");

scanf ("%ld", &num);

e=num;

a=num%10;

num=num/10;

b=num%10;

num=num/10;

c=num%10;

num=num/10;

d=num%10;

num=num/10;

num1=a*10000+b*1000+c*100+d*10+num;

printf ("The Reversed Number Is : %ld \n", num1);

if (e==num1)

printf ("The Entered and Reversed Numbers Are Equal\n");

else

printf ("The Entered and Reversed Numbers Are Not equal\n");

getch ();

}

OUTPUT



Enter The 5 Digit Number : 54345

The Reversed Number Is : 54345

The Entered and Reversed Number Are Equal





















Aim – WAP To Find The First Day of the Year

Code -



#include<stdio.h>

#include<conio.h>

void main()

{

int year, leapdays, days;

clrscr ();

printf ("Enter The Year To Find First Day (Year>1900) : ");

scanf ("%d", &year);

leapdays=(year-1900)/4;

days=leapdays+(year-1900);

days=days%7;

switch (days)

{ case 0:printf ("Monday\n");

break;

case 1:printf ("Tuesday\n");

break;

case 2:printf ("Wednesday\n");

break;

case 3:printf ("Thursday\n");

break;

case 4:printf ("Friday\n");

break;

case 5:printf ("Saturday\n");

break;

case 6:printf ("Sunday\n");

break;

}

getch ();

}



OUTPUT



Enter The Year To Find First Day (Year>1900): 2015

Thursday





Aim- WAP To Check Whether Entered Number Is Odd or Even

code-



#include<stdio.h>

#include<conio.h>

void main()

{

int x;

clrscr();

printf("Enter The Number To Check : ");

scanf("%d",&x);

if (x % 2 == 0)

printf("\n %d Is An Even Number");

else

printf("\n %d Is An Odd number");

getch();

}

OUTPUT

Enter The Number To Check: 41

41 Is An Odd Number













Aim – WAP To Compare Two Numbers And Print The Largest Number Without Using if

Code-



#include<stdio.h>

#include<conio.h>

void main ()

{

int a, b, c;

clrscr ();

printf ("Enter The Two Numbers Respectively: ");

scanf ("%d%d", &a, &b);

c=(a>b)?a:b;

printf ("The Largest Among The Two Number Is : %d", c);

getch ();

}

OUTPUT

Enter The Two Numbers Respectively : 26 10

The Largest Among Two Number Is : 26

















Aim - WAP To Reverse Four Digit Number

Code-



#include<stdio.h>

#include<conio.h>

void main ()

{

int num, a, b, c, num1;

clrscr ();

printf ("Enter The Four Digit Number : ");

scanf ("%d", &num);

a=num%10;

num=num/10;

b=num%10;

num=num/10;

c=num%10;

num=num/10;

num1=a*1000+b*100+c*10+num;

printf ("The Reversed Four Digit Number Is : %d", num1);

getch ();

}

OUTPUT

Enter The Four Digit Number : 1729

The Reversed Four Digit Number Is: 9271











Aim - Calculate The Sum & Percentage Of Marks Obtained In 5 Subject

Code-



#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c,d,e;

float sum, per;

clrscr();

printf("Enter The Marks In Five Subjects Respectively\n");

scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);

sum = a+b+c+d+e;

per = (sum / 5);

printf("\n\nThe Sum Of The Marks Obtained Is \t%f",sum);

printf("\n\nThe Percentage is \t%f",per);

getch();

}

OUTPUT

Enter The Marks In Five Subjects Respectively

56 65 98 78 74

The Sum Of The Marks Obtained Is 371.000000

The Percentage Is 74.20000