PLAY WITH CODING

Home Basic Program If & Else Loops Conversion Pattern logo

Basic C Program

Program to calculate sum of two number

Input - Output

Input
Enter 1st number : 8

Enter 2nd number : 5

Output
Sum of two number = 13

Algorithm

Step 1: START

Step 2: Take first number as input.

Step 3: Take second number as input.

Step 4: Print sum

Step 5: END

CODE


/* Sum of two number */

#include  <stdio.h>
int main()
{
      int num1,num2,sum;
      printf("Enter the first number : ");
      scanf("%d",&num1);
      printf("Enter the second number : ");
      scanf("%d",&num2);
      sum=num1+num2;
      printf("sum of two number = %d",sum);
    return 0;
}


/* Sum of two number */

#include  <iostream>
using namespace std;
int main()
{
      int num1,num2,sum;
      cout<<"Enter the first number : ";
      cin>>num1;
      cout<<"Enter the second number : ";
      cin>>num2;
      sum=num1+num2;
      cout<<"sum of two number = "<<sum;
    return 0;
}

OutPut

Enter first number : 8
Enter second number : 5

Sum of Two number = 13