Current time: 20 May 2024, 03:34 AM



c++ help
Away SmG FlasH™

Senior Member
Senior Member
******
11 Years of Service
Posts: 3,129
Threads: 102
Likes Received: 0 in 0 posts
Likes Given: 0
Joined: Apr 2013
Reputation: 141
Location: Summoners Rift
Halo GodCrystal DonatorSmoothThe BombDiscord WarriorGavel of TrinityDiamondGamerProgrammerThanks From Cloud
#2
Re: c++ help

Code:
int total = 0; //used to store the sum of the values in the array

for (int a = 0; a <= 12; a++) //use a for loop to access the values present in the array
    {
        if (array[a] < 0) //if the user enters a negative number (to exit program) it skips that value
        {
            continue;
        }
        cout << "Array Index " << a << "  Holds Value: " << array[a] << endl << endl; //prints out array index and the corresponding value
        total += array[a]; //total = total + the values in the array
        cout << "Total: " << total << endl; //display total
EDIT: If you have learnt functions, you should probably use them. Makes it really easy to understand and organized.
[Image: SPOILER_FlasH-1.gif]
14 Apr 2016, 05:20 AM
Find Reply


Messages In This Thread

Forum Jump:


Users browsing this thread:
SmG Gaming, © 2010-2024
Theme By: «SmG» Cloud
Edited by: «SmG» Wires