Swap two numbers by using Third variable:
Source Code :
Source Code :
#include<stdio.h>
#include<conio.h>
int main()
{
float A, B, C;
//using of float
printf("Enter value of A: ");
scanf("%f",&A);
//%f using for float
// float using for desimal value i.e; 0.00
printf("Enter value of B: ");
scanf("%f",&B);
C = A;
A = B;
B = C;
printf("\nAfter swaping value of A:%.f",A);
printf("\nAfter swaping value of B:%.f",B);
// \n use for new line or line break
return 0;
}
Output:#include<conio.h>
int main()
{
float A, B, C;
//using of float
printf("Enter value of A: ");
scanf("%f",&A);
//%f using for float
// float using for desimal value i.e; 0.00
printf("Enter value of B: ");
scanf("%f",&B);
C = A;
A = B;
B = C;
printf("\nAfter swaping value of A:%.f",A);
printf("\nAfter swaping value of B:%.f",B);
// \n use for new line or line break
return 0;
}
YouTube Watch :
No comments:
Post a Comment