Click here to Skip to main content
15,566,064 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to unlock locked file using Win32 API? Pin
kilt14-Sep-09 3:21
kilt14-Sep-09 3:21 
QuestionBeginner's Question 2 Pin
UKM_Student11-Sep-09 5:37
UKM_Student11-Sep-09 5:37 
AnswerRe: Beginner's Question 2 Pin
David Crow11-Sep-09 5:41
David Crow11-Sep-09 5:41 
GeneralRe: Beginner's Question 2 Pin
UKM_Student11-Sep-09 5:44
UKM_Student11-Sep-09 5:44 
GeneralRe: Beginner's Question 2 Pin
David Crow11-Sep-09 5:48
David Crow11-Sep-09 5:48 
GeneralRe: Beginner's Question 2 Pin
UKM_Student11-Sep-09 5:56
UKM_Student11-Sep-09 5:56 
GeneralRe: Beginner's Question 2 Pin
UKM_Student11-Sep-09 5:55
UKM_Student11-Sep-09 5:55 
GeneralRe: Beginner's Question 2 Pin
David Crow11-Sep-09 6:13
David Crow11-Sep-09 6:13 
UKM_Student wrote:
why is it wrong?


Because you wanted to use a while() loop to sum N1, N2, and N3. Given:

int N1, N2, N3;
while ()
{
    // what would go here?
}
How would that work?

UKM_Student wrote:
cout<<"Input 5 numbers.";


This should probably go outside the while() loop.

UKM_Student wrote:
My question is how should i put it so it would display" total: N1+N2+N3+N4+N5=XX "instead of adding all the numbers up then display "total:XX"


Given that you are not saving number each time through the loop, you can't.

Consider:

int count = 0, number[5];
  
while (count < 5)
{
    cin >> number[count];
    total += number[count];
    count++;
}
  
cout << endl << "total: ";
  
count = 0;
while (count < 5)
{
    cout << number[count];
    if (count < 4)
        cout << '+';
}
  
cout << '=' << total;


"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons


GeneralRe: Beginner's Question 2 Pin
UKM_Student11-Sep-09 6:23
UKM_Student11-Sep-09 6:23 
GeneralRe: Beginner's Question 2 Pin
Richard MacCutchan11-Sep-09 6:28
mveRichard MacCutchan11-Sep-09 6:28 
GeneralRe: Beginner's Question 2 Pin
UKM_Student13-Sep-09 5:34
UKM_Student13-Sep-09 5:34 
GeneralRe: Beginner's Question 2 Pin
Richard MacCutchan13-Sep-09 5:58
mveRichard MacCutchan13-Sep-09 5:58 
GeneralRe: Beginner's Question 2 Pin
UKM_Student14-Sep-09 0:48
UKM_Student14-Sep-09 0:48 
QuestionRe: Beginner's Question 2 Pin
David Crow11-Sep-09 6:40
David Crow11-Sep-09 6:40 
AnswerRe: Beginner's Question 2 Pin
UKM_Student11-Sep-09 6:45
UKM_Student11-Sep-09 6:45 
QuestionRe: Beginner's Question 2 Pin
David Crow11-Sep-09 6:54
David Crow11-Sep-09 6:54 
AnswerRe: Beginner's Question 2 Pin
UKM_Student11-Sep-09 7:16
UKM_Student11-Sep-09 7:16 
QuestionRe: Beginner's Question 2 Pin
David Crow11-Sep-09 7:21
David Crow11-Sep-09 7:21 
AnswerRe: Beginner's Question 2 Pin
UKM_Student11-Sep-09 7:26
UKM_Student11-Sep-09 7:26 
GeneralRe: Beginner's Question 2 Pin
David Crow11-Sep-09 7:32
David Crow11-Sep-09 7:32 
GeneralRe: Beginner's Question 2 Pin
UKM_Student11-Sep-09 7:38
UKM_Student11-Sep-09 7:38 
GeneralRe: Beginner's Question 2 Pin
UKM_Student11-Sep-09 6:27
UKM_Student11-Sep-09 6:27 
QuestionRe: Beginner's Question 2 Pin
David Crow11-Sep-09 6:35
David Crow11-Sep-09 6:35 
AnswerRe: Beginner's Question 2 Pin
UKM_Student11-Sep-09 6:44
UKM_Student11-Sep-09 6:44 
QuestionHow to control the size of MessageBox Pin
Software200711-Sep-09 4:21
Software200711-Sep-09 4:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.