Skip to main content

C Program to Swap Two Numbers

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include<stdio.h>
int main() {
      double first, second, temp;
      printf("Enter first number: ");
      scanf("%lf", &first);
      printf("Enter second number: ");
      scanf("%lf", &second);
 
      temp = first;
 
      first = second;
 
      second = temp;
 
      printf("\nAfter swapping, firstNumber = %.2lf\n", first);
      printf("After swapping, secondNumber = %.2lf", second);
      return 0;
}

Output:

1
2
3
4
5
Enter first number: 2.50
Enter second number: 5.75
 
After swapping, firstNumber = 5.75
After swapping, secondNumber = 2.50

Comments

Popular posts from this blog

How To Make a Pagination Using HTML and CSS

  CSS Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 <style> . center {    text-align : center ; }   .pagination {    display : inline-block ; }   .pagination a {    color : black ;    float : left ;    padding : 8px 16px ;    text-decoration : none ;    transition : background-color . 3 s;    border : 1px solid #ddd ;    margin : 0 4px ; }   .pagination a.active {    background-color : #002468 ;    color : white ; }   .pagination a:hover:not(.active) { background-color : #ddd ;} </style> HTML Code 1 2 3 4 5 6 7 8 9 10 11 12 < div class = "center" >    < div class = "pagination" >    < a href = "#" >&laquo;</ a >    < a href = "#" >1</ a >    < a href = "#" class = "active" >2</ a >    < a href = "#" ...