This is a discussion on About mathematical programming problem... within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h>int num1; void a() { printf( "%f\n",3.40*num1 ); } void b() { printf( "%f\n",11.30*num1 ); } void c() ...

1. ## About mathematical programming problem...

Code:
```#include <stdio.h>int num1;
void a()
{
printf( "%f\n",3.40*num1 );
}
void b()
{
printf( "%f\n",11.30*num1 );
}
void c()
{
printf( "%f\n",4.78*num1 );
}

int main()
{
while (1)
{

int input;

printf ("Enter pairs of item numbers and quantities.\n");
printf ("Enter -1 for the item number to end input.\n");

scanf ("%d %d", &input ,&num1);
switch ( input ) {
case 1:            /* Note the colon, not a semicolon */
a();
break;
case 2:
b();
break;
case 3:
c();
break;
case -1:
printf( "The total retail value was USD:\n");
break;
default:
printf( "Invalid product code:  %d,input\n" );
break;

}}
getchar();

}```
what i write the programming is input (product number)<space>(quantity) then it will print the (price according the product number * quantity) .
but what i want the program is it can total up all the different product price once i type -1.

Code:
```Enter pairs of item numbers and quantities.
Enter -1 for the item number to end input.
1 1
2 1
3 1
4 1
Invalid product code:  4
1 1
-1
The total retail value was: USD22.88```
This is the output what i need.
how to write the program that once i input "1 1" then it still can input continuously until i input -1 it will show up sum of the price?