Pages

Friday, July 1, 2016

Algorithm to C program conversion

/* Example of Algorithm to C program conversion.

Problem Definition: Write an algorithm to add given two numbers.

Step 1: Start.
Step 2: Read two numbers A and B.
Step 3: Total = A+B.
Step 4: Display Total.
Step 5: Stop.

*/

#include<stdio.h>
int main()
{
 int A, B, Answer;

 printf("Enter number A:");
 scanf("%d",&A);

 printf("Enter number B:");
 scanf("%d",&B);

 Answer = A + B;
 printf("%d", Answer);
 return 0;
}


Output of program:

Enter number A:5
Enter number B:10
15

No comments:

Post a Comment