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

Crazy About Her | Netflix Official Site

Netflix Netflix UNLIMITED TV SHOWS & MOVIES JOIN NOW Sign Out Crazy About Her 2021 | 18+ | 1h 42m | Romantic Comedies After spending a wild night together, Adri discovers the only way to see Carla again is to become a patient at the psychiatric center where she resides. Starring: Álvaro Cervantes,Susana Abaitua,Luis Zahera Watch all you want. JOIN NOW Videos Crazy About Her Trailer: Crazy About Her More Details Watch offline Available to download Genres Spanish , Comedies , Dark Comedies , Romantic Movies , Romantic Comedies This movie is... Cynical , Offbeat , Intimate , Inspiring , Romantic Audio English , English , European Spanish - Audio Description , European Spanish [Original] , European Spanish - Audio Description , European Spanish [Original] Subtitles English , English , European Spanish Cast Álvaro Cervantes Susana Abaitua Luis Zahera Clara Segura Aixa Villagrán Paula Malia Nil Cardoner Txell Aixendri Alberto San Juan More Originals Coming Soon Murder by the Coast...

C Program to Add Two Integers

2 3 4 5 6 7 8 9 10 11 12 13 #include <stdio.h> int main() {           int num1, num2, sum;             printf ( "Enter two integers: " );      scanf ( "%d %d" , &number1, &number2);        sum = num + num2;                  printf ( "%d + %d = %d" , num, num, sum);      return 0; } Output: 1 2 3 Enter two integers: 61 39 61 + 39 = 100