Develop an algorithm. flowchart and program to add two numbers
Answers
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values for num1, num2.
Step 4: Add num1 and num2 and assign the result to a variable sum.
Step 5: Display sum
Step 6: Stop
#include<stdio.h>
int main()
{
int num1,num2,sum;
printf("\n Enter the first number to be added: ");
scanf("%d",&num1);
printf("\n Enter the second number to be added: ");
scanf("%d",&num2);
sum = num1 + num2;
printf("\n The sum of two numbers is: %d",sum);
return 0;
}
Answer -
Algorithm-
step 1 : start
step 2 : input a,b
step 3 : sum=a+b
step 4 : print sum
step 5 : end
Flow chart -
A flow chart is a graphical representation of the information of the structure of a problem.
The flow chart to add Two numbers is in the attachment.
Program -
#include<stdio.h>
#include<conio.h>
void main ()
{
int a,b,sum=0;
clrscr();
printf("Enter any two numbers");
scanf("%d%d",&a,&b);
sum = a+b;
printf ("Sum=%d",sum);
getch();
}