Technologies

C

write a c program to swap two numbers
(adsbygoogle = window.adsbygoogle || []).push({});
(adsbygoogle = window.adsbygoogle || []).push({});
(adsbygoogle = window.adsbygoogle || []).push({});

CLanguage

Wednesday, 21 Jun 2017

1099

0

0

Write a C Program for the following :
# 1. swapping of two numbers with out using third variable

# 2. swapping of two numbers using third variable

- swapping of two numbers with out using third variable.
- swapping of two numbers using third variable.

#including <stdio.h> main() { int a, b; printf("Enter any two positive integers : "); scanf("%d %d", &a, &b); printf("Before swapping : a = %d and b = %d \n ", a, b); a = a + b; b = a - b; a = a - b; printf("After swapping : a = %d and b = %d", a, b); }

input : Enter any two positive integers : 2 5

output : Before swapping : a = 2 and b = 5

After swapping : a = 5 and b = 2

output : Before swapping : a = 2 and b = 5

After swapping : a = 5 and b = 2

#includingmain() { int a, b, t; printf("Enter any two positive integers : "); scanf("%d %d", &a, &b); printf("Before swapping : a = %d and b = %d \n ", a, b); t = a; a = b; b = t; printf("After swapping : a = %d and b = %d", a, b); }

input : Enter any two positive integers : 2 5

output : Before swapping : a = 2 and b = 5

After swapping : a = 5 and b = 2

output : Before swapping : a = 2 and b = 5

After swapping : a = 5 and b = 2

Post Article

Upload Youtube Video

CLanguage

Wednesday, 21 Jun 2017

1099

0

0

Popular Post

- Write an algorithm and draw the flowchart to find the largest number among the three numbers?
- Write an algorithm an draw flowchart to find factorial of a number?
- Write an algorithm and draw the flowchart to find whether a given number is even or odd?
- Write an algorithm and draw the flowchart to Swap two integers?
- Write an algorithm an draw the flowchart to compute the average of the three numbers?
- Write an algorithm and draw the flowchart to find the largest number amoug two numbers?
- write a c program to swap two numbers
- How to write a algorithm?
- What is mean by Operator Precedence and Associativity in C Language?
- C Languages Relational Operators

All contents are copyright of their authors