nid help to do subtract

#include <stdio.h>
void main()
{
int I, N=0;
float number,sum=0, number1;
printf("How many numbers do you want to add:");
scanf("%d",&N);
N=N-1;
for (I=1; I<=N; I++)
{
printf("PLease Enter The Biggest Number To Be SubTract");
scanf("%f",&number1);
printf("Please enter number %d:", I);
scanf("%f",&number);
sum = number1 - number;
}
printf("Total = %.2f\n",sum);
}
I hvae try searching but could not find can anyone of ur help me to do a subtract >.< Thanks :)
I would suggest you to put all your code in the code brackets provided by this forum

I am not a expert programmer , but i think the below line
printf("Total = %.2f\n",sum);

should be inside the loop so that the output for every subtraction is shown .

Also can you tell me what exactly you want to do ?

Last edited on
Hm.. i onli wan to do a subtract of a loop but i onli gt addition and could not get subtraction of a loop.........
the output of this should be like this:How many numbers do you want to subtract: 3
Please enter number 1: 12
Please enter number 2: 2.5
Please enter number 3: 0.25
12 - 2.5 - 0.25 = 9.25
closed account (DSLq5Di1)
I think this is what you intended..
1
2
3
4
5
6
7
8
9
10
11
    printf("PLease Enter The Biggest Number To Be SubTract");
    scanf("%f",&sum);

    for (I=1; I<=N; I++)
    {
        printf("Please enter number %d:", I);
        scanf("%f",&number);
        sum = sum - number;
    }

    printf("Total = %.2f\n",sum);
THANKS!!!!!!! <3
Topic archived. No new replies allowed.