#include "stdafx.h"
#include <iostream>
int subtract(int x, int y)
{
return x - y;
}
int main()
{
using namespace std;
cout << "How much money does the desired item cost?";
int x;
cin >> x;
cout << "How much money do you have currently?";
int y;
cin >> y;
cout << "You need this much more: " << subtract(x, y) << endl;
return 0;
}
int main()
{
int x = 0;
if (x == 0)
{
x = 1;
}
else
{
x = 2;
}
return 0;
}
int main()
{
int x = 0;
x = x == 0 ? 1 : 2;
return 0;
}
int main()
{
int x = 0;
if (x == 0)
{
x = 1;
}
else
{
x = 2;
}
return 0;
}
int main()
{
int x = 0;
x = x == 0 ? 1 : 2;
return 0;
}
#import <iostream>
using namespace std;
int main() {
int items = 0;
int i;
float cost;
float currentMoney;
float total;
cout << "How many items? ";
cin >> items;
cout << "How much money do you have? ";
cin >> currentMoney;
for(i = 0; i < items; i++) {
cout << "Enter cost of item: ";
cin >> cost[i];
total += cost[i];
}
if(total <= currentMoney) {
cout << "You have enough money.\n";
cout << "Total Cost: " << total << endl;
}
else if(total > currentMoney) {
cout << "You do not have enough money. You need " << total - currentMoney << " more.\n";
cout << "Total Cost: " << total << endl;
}
}
#import <iostream>
using namespace std;
int main() {
int items = 0;
int i;
float cost;
float currentMoney;
float total;
cout << "How many items? ";
cin >> items;
cout << "How much money do you have? ";
cin >> currentMoney;
for(i = 0; i < items; i++) {
cout << "Enter cost of item: ";
cin >> cost;
total += cost;
}
if(total <= currentMoney) {
cout << "You have enough money.\n";
cout << "Total Cost: " << total << endl;
}
else if(total > currentMoney) {
cout << "You do not have enough money. You need " << total - currentMoney << " more.\n";
cout << "Total Cost: " << total << endl;
}
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.