repl.it
@EverettErlandso/

Add/Subtract Numbers

C

No description

fork
loading
Files
  • main.c
main.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
29
30
31
32
33
/*Everett Erlandson
File: Add/SubNumbers.c
Purpose: To find the sum & difference of numbers*/ 

#include <stdio.h>

int main(void) {

//Introduction to the user - use printf statements
 printf("This program will find the sum and difference of numbers.\n\n"); 

  //Declare variables - float or double (for decimals) or int (for integers)
  double sum;
  double difference;
  int original;
  double input;

  //Coder assigns value to variables
original = 987543288;

// User assigns value to variables - need printf statement followed by a scanf statement
printf("What number would you like to add or subtract from the original number?  ");
scanf("%lf", &input);

//Manipulations (aka calculations) to determine the value of other variables
difference = original - input;
sum = original + input;

//Display results - printf statements with variable placeholders imbedded like %lf, %f, or %d depending
printf("/n/nThe difference between the original (%d) and your input (%lf)is %lf.", original, input, difference);
  
  return 0;
}
Fetching token
?