Trouble With a for Loop

Thank you for looking at this.

So what I think I'm trying to do here is
Ask for an input of a how many times
that number is going to be compared to Count
if count is less then Number add one to Count
For x amount of time
ask for input of Num
and Num to total
display total??

I think it looks right but it just ask for the two inputs and then displays
total with nothing there?

I haven't finished the program I'm trying to do it in segments and not sure if that could be part of the problem?


/********************************************************************
*Program Name : Lab 4 - CSC110 Program Template
*Author :
*Date :
*Course/Section : CSC110-???
*Program Description: This lab introduce repitions statments. Your
* Program will as the user for how many mubers to input. You will
* then code a FOR loop to add up the numbers. Display the sum and
* pause the screen. THEN your program will input an unknown number
* of positive integers. Count and display the number of even
* numbers. Enter a -1 to stop entering in numbers
*
*BEGIN Lab 04 - Repitions
* Init total to 0
* Input count of how many numbers to input
* FOR (Each number to input)
* Enter the number
* Add the number to the total
* END FOR
* Clear the screen
* Display the total
* Pause the screen
* Clear the screen
* Init count of even numbers to 0
* Input a positive number (or QUIT)
* WHILE (input number is not QUIT)
* IF (Input Number is even)
* Add 1 to count of even numbers
* END IF
* Get next input number or quit
* END WHILE
* Display the count of even numbers
*END Lab 04 - Repetition
********************************************************************/

#include <iostream>
#include <iomanip>
using namespace std;

void main()
{
//local constants
const int COUNT = 0;
const int QUIT = -1;
//local variables
int Number;
int Num1;
int Num2;
int Count = 0;
int Total = 0;

/**************************start main program*********************/


//Prompt for number input
cout << "\n\n\n\n\n\n\n";
cout << setw(50) << "------------------------------" << endl;
cout << setw(50) << " Enter an amount of numbers " << endl;
cout << setw(50) << "------------------------------" << endl;
cout << "\n" << setw(46) << "Amount: ";
cin >> Number;

for (Count = 0; Count < Number; Count++);

{
cout << setw(50) << "Enter first Number: " << endl;
cin >> Num1;
Total = Total + Num1;
}

cout << setw(50) << "Total" << endl;
}
Homework questions are best asked in the "Beginner Forum". Please encode code inside of code tags so it is more legible.

You don't output the Total variable, just a "Total" string literal.
Last edited on
Sorry about that. I thought i was in the "Beginners Forum". But not sure what you mean by code tags. and should I post my follow up question here or just start a new thread.

thanks for pointing out that slip up. guess i really am a beginner.
But the next problem I run into is. that it won't run for the giving amount input.??
It's hard to follow what you are trying to accomplish here. One reason you aren't getting far is because at the end of "for(Count = 0; Count<Number; Count++)" you don't need another semicolon. That is a syntax error. Also, like PanGalactic said, you have quotes around Total which is telling the compiler to output a string, not your actual variable Total.

-David Garza UAT Student
Topic archived. No new replies allowed.