•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 401,421 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,915 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 136 | Replies: 4
![]() |
•
•
Join Date: Jul 2008
Posts: 47
Reputation:
Rep Power: 0
Solved Threads: 0
hi ppl
im back here, but with another problem in another code.
in this one i have to count how many sellers reached the top sells.
thing is that if i put one that reached the top at the end, the program doesnt count it, it counts only the first ones before the last one.
i mean, for example, i put:
code of employee = 1
sells = 20
code of employee = 2
sells = 10
code of employee = 3
sells = 20
code of employee = 0
the code of employee = 3
sells = 20
doesnt count
shall i use a for loop instead?? or a for loop inside the while loop, just to count the employees who reach that top??
im back here, but with another problem in another code.
in this one i have to count how many sellers reached the top sells.
thing is that if i put one that reached the top at the end, the program doesnt count it, it counts only the first ones before the last one.
i mean, for example, i put:
code of employee = 1
sells = 20
code of employee = 2
sells = 10
code of employee = 3
sells = 20
code of employee = 0
the code of employee = 3
sells = 20
doesnt count
shall i use a for loop instead?? or a for loop inside the while loop, just to count the employees who reach that top??
cplusplus Syntax (Toggle Plain Text)
// maximo_ventas.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> int main(int argc, char* argv[]) { using namespace std; int legajo, vendedor = 0; float ventas_vendedor, aux_ventas = 0; cout << " Ingrese legajo del vendedor: "; //code of employee, number wich i use to identify him cin >> legajo; cout << "\n"; while (legajo != 0) { cout << "Ingrese importe total de ventas de ese vendedor: "; cin >> ventas_vendedor; cout << "\n"; while (ventas_vendedor > aux_ventas) // here i have the max sells made { aux_ventas = ventas_vendedor; vendedor +=1; // here i count the people who reached that. } cout << " Ingrese legajo del vendedor: "; cin >> legajo; cout << "\n"; } cout << " El maximo de ventas fue: " << aux_ventas << "\n"; cout << " El total de vendedores que alcanzaron ese maximo fue: " << vendedor << "\n"; return 0; }
•
•
Join Date: Jul 2008
Posts: 369
Reputation:
Rep Power: 3
Solved Threads: 57
You have absolutely useless inner while loop. Replace it:
cplusplus Syntax (Toggle Plain Text)
if (ventas_vendedor > aux_ventas) // here i have the max sells made { aux_ventas = ventas_vendedor; vendedor = 1; // Now we have one and only one leader! } else if (ventas_venderor == aux_ventas) ++vendedor; // addition to the family...
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Counter help (C++)
- problem with counter (PHP)
- bank system problem !!!! (C++ programming) (C++)
- c:\counter.cab:\counter.exe (Viruses, Spyware and other Nasties)
- letter and word counter (C)
- About:blank trusted start page and freshbar problem...please help (Viruses, Spyware and other Nasties)
- Windows Interface has changed..a serious problem! (Windows 9x / Me)
- Array in talbe (problem) (C)
Other Threads in the C++ Forum
- Previous Thread: Pls help me... in array problem..
- Next Thread: Turbo C++ not working..


Linear Mode