1. Write a program to take two values from user and swap their values in C Language - Program code
2. Write a Program to take three input from user print them ascending and descending order in C Language - Program code
1.
Write a program to take two values from user and swap their values in C language - Program code
Program Code :-
/* Write a program to take two values from user and swap their values */
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,temp;
clrscr();
printf("Enter The value of A : ");
scanf("%d",&a);
printf("Enter the value of B : ");
scanf("%d",&b);
printf("Before Swapping >>> ");
printf("A=%d , B=%d",a,b);
temp=a;
a=b;
b=temp;
printf("\nAfter Swapping >>> ");
printf("A=%d , B=%d",a,b);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,temp;
clrscr();
printf("Enter The value of A : ");
scanf("%d",&a);
printf("Enter the value of B : ");
scanf("%d",&b);
printf("Before Swapping >>> ");
printf("A=%d , B=%d",a,b);
temp=a;
a=b;
b=temp;
printf("\nAfter Swapping >>> ");
printf("A=%d , B=%d",a,b);
getch();
}
Program Code Download :-
2.
Write a Program to take three input from user print them ascending and descending order in C program - Program Code
Program Code :-
/* Write a Program to take three input from user print them ascending and descending order */
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the value of A : ");
scanf("%d",&a);
printf("Enter the value of B : ");
scanf("%d",&b);
printf("Enter the value of C : ");
scanf("%d",&c);
if(a>=b && a>=c)
{
if(b>=c)
{
printf("Descending : %d %d %d\n",a,b,c);
printf("\nAscending : %d %d %d",c,b,a);
}
else
{
printf("Descending : %d %d %d\n",a,c,b);
printf("\nAscendiing : %d %d %d",b,c,a);
}
}
else if(b>=a && b>=c)
{
if(a>=c)
{
printf("Descending : %d %d %d\n",b,a,c);
printf("Ascending : %d %d %d",c,a,b);
}
else
{
printf("Descending : %d %d %d\n",b,c,a);
printf("Ascending : %d %d %d",a,c,b);
}
}
else
{
if(a>=b)
{
printf("Descending : %d %d %d\n",c,a,b);
printf("Ascending : %d %d %d",b,a,c);
}
else
{
printf("Descending : %d %d %d\n",c,b,a);
printf("Ascending :%d %d %d",a,b,c);
}
}
getch();
}
/* Write a Program to take three input from user print them ascending and descending order */
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the value of A : ");
scanf("%d",&a);
printf("Enter the value of B : ");
scanf("%d",&b);
printf("Enter the value of C : ");
scanf("%d",&c);
if(a>=b && a>=c)
{
if(b>=c)
{
printf("Descending : %d %d %d\n",a,b,c);
printf("\nAscending : %d %d %d",c,b,a);
}
else
{
printf("Descending : %d %d %d\n",a,c,b);
printf("\nAscendiing : %d %d %d",b,c,a);
}
}
else if(b>=a && b>=c)
{
if(a>=c)
{
printf("Descending : %d %d %d\n",b,a,c);
printf("Ascending : %d %d %d",c,a,b);
}
else
{
printf("Descending : %d %d %d\n",b,c,a);
printf("Ascending : %d %d %d",a,c,b);
}
}
else
{
if(a>=b)
{
printf("Descending : %d %d %d\n",c,a,b);
printf("Ascending : %d %d %d",b,a,c);
}
else
{
printf("Descending : %d %d %d\n",c,b,a);
printf("Ascending :%d %d %d",a,b,c);
}
}
getch();
}
Program Code Download :-
0 Comments
If You have any query, Please let me know..