-
Notifications
You must be signed in to change notification settings - Fork 2
/
calculator.c
28 lines (16 loc) · 862 Bytes
/
calculator.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// C example by Darren Rainey http://github.com/DarrenRainey
#include <stdio.h> // Include standard input and output header file
int main()// Start main function
{
int buffer[10]; // Set buffer int
printf("Input 1: "); // Ask for first number
scanf("%d",&buffer[0]); // Take input and store it in the buffer int
printf("Input 2: "); // Ask for input 2 and store it as a int
scanf("%d",&buffer[1]); // Store previous input in buffer 2
printf("Input 1 Was %d\n",buffer[0]); // Prints input 1 from buffer
printf("Input 2 Was %d\n",buffer[1]); // Prints Input 2 from buffer
int math; // Set math as int
math = buffer[0] + buffer[1]; // Add the buffers and save it to the math int
printf("Total Is %d\n",math); // Print total
return 0; // Exit if no errors
}