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


wap To Print Value One less than & One More Than The Given Value & Print Their Sum .

Code –



#include<stdio.h>

#include<conio.h>

void main ()

{

int a,b,c,sum;

clrscr();

printf("Enter The Value \t");

scanf("%d",&a);

b= a-1;

c= a+1;

sum=a+b+c;

printf("\nThe Value One less Than The Given Value %d",b);

printf("\nThe Value One Greater Than The Given Value %d",c);

printf("\nThe Value Of Their Sum Is %d",sum);

getch();

}

OUTPUT

Enter The Value 5

The Value One Less Than The Given Value 4

The Value One Greater Than The Given Value 6

The Value Of Their Sum Is 15


-     To print ASCII value of Entered Character
      Code-

      #include<stdio.h>
      #include<conio.h>
       void main()
        {
        char a;
        clrscr(); 
     printf("Enter The Character Whose ASCII value You Want To            Print \t ");
       a = getchar();
       printf("\n The ASCII Value of Entered Character Is %d", a);
       getch();
}
   
      OUTPUT
       Enter The Character Whose ASCII value You Want To
        Print    a

       The ASCII Value of Entered Character Is 97








Monday 8 June 2015

5.Aim - WAP To Swap Two Numbers Using Third Variable
Code-

#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b,c;
 clrscr();
 printf("Enter The Value Of a and b respectively : ");
 scanf ("%d%d",&a,&b);
 c=a+b;
 b=c-b;
 a=c-b;
 printf("\nThe Values Of a and b After Swapping is %d %d",a,b);
 getch();
}

OUTPUT
Enter The Values Of a and b respectively : 35  93
The Values Of a and b After Swapping is 93 & 35






4.Aim - WAP To Swap Two Numbers Without Using Third Variable
Code –

#include<stdio.h>
#include<conio.h>
void main()
{
 int a,b;
 clrscr();
 printf("Enter The Value Of a and b respectively : ");
 scanf ("%d%d",&a,&b);
 a=a+b;
 b=a-b;
 a=a-b;
 printf("\nThe Values Of a and b After Swapping is %d & %d",a,b);
 getch();
}

OUTPUT
Enter The Values Of a and b respectively : 35  93
The Values Of a and b After Swapping is 93 & 35






3.Aim -WAP To Perform Various Arithmetic operations
Code-
#include<stdio.h>
#include<conio.h>
void main()
{
 int a, b, sum, diff, pro, div;
 clrscr ();
 printf ("Enter The Two Numbers : ");
 scanf ("%d%d", &a, &b);
 sum=a+b;
 diff=a-b;
 pro=a*b;
 div=a/b;
 printf ("Sum=%d\n", sum);
 printf ("Difference=%d\n", diff);
 printf ("Product=%d\n", pro);
 printf ("Quotient=%d\n", div);
 getch ();
}

OUTPUT
Enter The Two Numbers : 19 21
Sum = 40
Difference = -2
Product = 399
Quotient = 0




2.Aim -  WAP To Convert Celsius Into Farenheit
Code-

#include<stdio.h>
#include<conio.h>
void main ()
{
 float cel, faren;
 clrscr ();
 printf ("Enter The Temperature In Degree Celsius: ");
 scanf ("%f", &cel);
 faren=(9*cel/5)+32;
 printf ("The Equivalent Temperature In Farenheit is : %f", faren);
 getch ();
}

OUTPUT
Enter The Temperature In Degree Celsius: -45
The Equivalent Temperature In Fahrenheit is : -113




 1 Programming:

Aim -  Wap to print hello.
Code-
 #include<stdio.h>
#include<conio.h>
void main ()
{
 printf ("Hello");
 getch ();
}

 Output-



Hello