Originally Posted by
Cofex
Yeah, exaclty! But they won't be able to divide it straight away...
1) They first have to type in the two variables
2) Secound they will choose eather if they want to divide or multiply, like so:
Try to convert this pseudocode into a program. The code below doesn't do anything similar to that.
Code:
void PellerK(double *Produkt, double *Kvot){
I guess your two parameters should be the numbers you want to multiply/divide. Then the variable names are misleading and the parameters should be called like "number1" and "number2". And I don't think you need them to be pointers but return the actual result from the calculation.
Code:
printf("Produkt eller Kvot?\n"); /* Here it asks for eather to Multiply or Divide */
scanf("%lf %lf",Produkt,Kvot);
You ask the user whether s/he wants to multiply or divide and expect two doubles as input? If I see a question like that I would input "*" or "/" or perhaps "multiply" or "divide" but I would never try to input the actual numbers for the calculation.
Code:
if (PellerK == Produkt) { /* Multiply */
printf("Produkten blir = %d\n");
"PellerK" is a function and in this expression it's a pointer to the function. So that's completely wrong.
And if you use "%d" you also need to provide the value to print.
You need to think about the whole process step by step and write each step down. Then you need to translate this pseudocode into valid C code.
If you don't have a clear plan for your program you won't be able to finish it.
For example you could start with a list like
Code:
1) Ask user for first number
2) Read input from user and store value in variable "number1"
3) Ask user for second number
...
and only after you have written down every single step you turn on the computer and write the C code for it.
Bye, Andreas