Write the Flowchart to swap any two number with another variable?
(hint = This is the Question of Class 9 and 10)
Answers
Answered by
2
Answer:
Let's see a simple c example to swap two numbers without using third variable.
#include<stdio.h>
int main()
{
int a=10, b=20;
printf("Before swap a=%d b=%d",a,b);
a=a+b;//a=30 (10+20)
b=a-b;//b=10 (30-20)
a=a-b;//a=20 (30-10)
Answered by
2
Answer:
Algorithm and Flowchart to Swap Two Integer Numbers
Declare a variable a,b and c as integer; Read two numbers a and b; c=a; a=b; b=a; Print a and b.
STEP 1: START STEP
2: ENTER A, B STEP
3: PRINT A, B STEP
4: A = A + B STEP
5: B= A - B STEP
6: A =A - B STEP
7: PRINT A, B STEP
8: END.
Similar questions
Math,
29 days ago
English,
29 days ago
Accountancy,
29 days ago
English,
1 month ago
Math,
9 months ago
Social Sciences,
9 months ago