A question about C++
I have just made a simple code about adding all the numbers that user entered; how do i make it to subtract the first number with the other numbers that user have entered; Below is my code; #include <iostream> using namespace std; int main(){ int a; int x; int y; int total; cout << "What do you want to do with these numbers" << endl; // sum = 1, sub = 2, multi = 3, div =4 cin >> a; cout << "How many number do you have to perform?" << endl; cin >> x; if ( a == 1) { for (int z = 1; z <= x; z++) { cin >> y; total += y; } } if ( a == 2) { for (int z = 1; z <= x; z++) { cin >> y; total -= y; } } cout << total; return 0; }