Skip to content

Instantly share code, notes, and snippets.

@NitishDiwakar
Created May 28, 2017 07:09
Show Gist options
  • Save NitishDiwakar/7d0712f05a92b697b444de9e6f08356a to your computer and use it in GitHub Desktop.
Save NitishDiwakar/7d0712f05a92b697b444de9e6f08356a to your computer and use it in GitHub Desktop.
Addition in C
#include<stdio.h>
int main()
{
// declare three variables.
int a = 0, b = 0, sum = 0;
printf("Please enter a number: \n" );
// read first variable
scanf("%d", &a);
printf("Please enter second number: \n" );
// read second variable
scanf("%d", &b);
// calculate sum of two variables
sum = a + b;
// show result
printf("The sum of %d and %d is %d \n", a, b, sum );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment