sarah - 8 days ago 4x

C Question

I am new to the coding world, and have been struggling a lot. In my course "intro to programming" I will be learning about the C language. I needed help on how to do an arithmetic sequence in visual studio using and containing two constant values for weeks in a year (should be set to 52) and months in a year (value should be set to 12).

I will list the directions below.

write a program that takes numeric inputs from a user, uses these values in various math calculations, and then displays the results of these computations to the user at certain intervals within program.

User will have to enter two numeric values (value A and Value B)and program should contain two constant values for weeks in yr (need to set to 52) and months in a year (need to set to 12)

first facsimile should look like this

Please enter Value A: ## (in this case i wanted to use 10)

Please enter Value B: ## (in this case i wanted to use 20)

after numbers are entered program should conduct following calculations. (results to calculations should be stored at a later stage in the program.

- The difference of Value A (10) subtracted from Value B (20)
- the result of value B (20) added to Value B(20)
- The product of multiplying Value A (10) by Value b(20)
- The quotient of dividing Value B (20) by the answer of calculation 2
- The remainder of dividing the constant value for weeks in a year (52) by the constant value for months in a year (12)
- The product of multiplying the answer of Calculation 1 by the answer of Calculation 3

after these are completed the program should then display the results of each calc.

facsimile must look like this

Program 1 Result (stage 1)

Results for calculation 1: ##

Results for calculation 2: ##

Results for calculation 3: ##

Results for calculation 4: ##

Results for calculation 5: ##

Results for calculation 6: ##

after displaying the results of first six calcs, program should continue with four more calcs

- th sum of the product of value a by calculation 1 and the product of value b by calculation 2
- the quotient of dividing the product of value a, value b, and calculation 1's results by the results of calculation 4
- the answer to adding value a to the quotient by dividing the result of calculation 2 by the product of calc 1's results, calcs 3's results, and calc 4's results
- the sum of the result of calc 2 and three more times te result of calc 1

once those next four calculations are completed program should display results of each calc again. numerical results all rounded up the calculated answer to the converted ten-thousandth decimal position.

facsimile (including both stages 1-6 and 7-10) should look like this

Please enter Value A: ####

Please enter Value B: ####

Program 1 Result (stage 1)

Results for Calculation 1: ####

Results for Calculation 2: ####

Results for Calculation 3: ####

Results for Calculation 4: ####

Results for Calculation 5: ####

Results for Calculation 6: ####

Program 1 Result (stage 2)

Results for Calculation 7: ####

Results for Calculation 8: ####

Results for Calculation 9: ####

Results for Calculation 10:####

what i have so far. again i'm new to this so please triple check what i have so far and please assist me in where i went wrong, how to fix them. etc.

`#include <stdio.h>`

int

main(void)

{

double a, b, c, d, e, f, g, h;

printf("Please enter Value A> ");

scanf("%lf", &a);

printf("Please enter Value B> ");

scanf("%lf", &b);

c = b - a;

d = b + b;

e = a * c;

f = b / d;

g = DO NOT KNOW HOW TO MAKE CONSTANTS??

h = c * e;

printf("The result of the difference of %f subtracted from %f is %f\n", a, b, c);

printf("The result of %f added to %f is %f/n", b, b, d);

printf("The result of the product of %f multiplying by %f is %f\n", a, b, e);

printf("The result of the quotient of dividing %f by %f is %f\n", b, d, f);

printf("The result of the remainder of dividing the ?? in a year by the ?? in a year is %f/n",??, ??, ??);

printf("The result of the product of multiplying the answer of %f by the answer of %f is %f/n", c, e, h);

i =

j =

k =

l =

`printf("The result of the sum of the product of %f`

return (0);

}

Answer

In C, there are two different types of constants:

```
#define token [value]
// example:
#define NUMBER_X 100
```

```
static int const varX = 5
```

The last one, you could achieve by enum too, for example.

Source (Stackoverflow)

Comments