473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

A problem!!

Hi guys!!..

i'm new in this site..i hope u welcome me..

okay..

i'm studying c++.. i have this problem.. can someone help me..

Write a program that finds the smallest,largest,and average of three numbers enterd.
Use a do..while loop.

This is a simple output.. -->

----------------
Enter the first number: 5
Enter the next number: 16
Enter the next number: 1
The smallest number entered: 1
The largest number entered: 16
The average of the numbers entered: 7.33
-------------

i tried everything i know.. but nothing in mind.. :P
lol..
Dec 3 '06 #1
3 1189
DeMan
1,806 1GB
It might be an idea to post some of what you've tried......

In the meantime, consider this (I am assuming negative numbers are out of the question).....

set four temporary ints:
- one called smallest (or similar) to the largest int you can
- one called largest to 0.
- one called total to 0;
- one called counter to 0
as each number is entered, top of do while loop
counter is incremented.
Then if inputt is bigger than largest, it becomes largest.
Likewise if it is smaller than smallest, it becomes smallest.
Add input to total.
Check exit condition (the while part - you will have to choose some input that should not be entered that can signal exit) and start again if we didn't find it.
We have finished so display smalles, largest and average (ie total/counter).

It would be nicer (I Think) to use a while than a do-while if you are allowed.

This is the logic for the program. If you would like examples on how to code parts of this, please provide evidence of
i tried everything i know.. but nothing in mind..
Dec 3 '06 #2
thnx ...

i'm going to collage right now.. i'll try to do it later.. and post the ideas ..


;)
Dec 11 '06 #3
void sol(int &a,int &b, int &c)
{
int t=a>b?a:b;
t=t>c?t:c; //greatest ->t
int t1=a<b?a:b;
t1=t1<c?t1:c; //smallest->t1
float t2=a+b+c/3.0; //avg->t2
///rest is just output
}

gagan


Hi guys!!..

i'm new in this site..i hope u welcome me..

okay..

i'm studying c++.. i have this problem.. can someone help me..

Write a program that finds the smallest,largest,and average of three numbers enterd.
Use a do..while loop.

This is a simple output.. -->

----------------
Enter the first number: 5
Enter the next number: 16
Enter the next number: 1
The smallest number entered: 1
The largest number entered: 16
The average of the numbers entered: 7.33
-------------

i tried everything i know.. but nothing in mind.. :P
lol..
Dec 11 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
9
by: Sudesh Sawant | last post by:
Hello, We have an application which communicates using remoting. There is a server which is a Windows Service. The server exposes an object which is a singleton. The client is a Web Application...
117
by: Peter Olcott | last post by:
www.halting-problem.com
0
by: James Griffiths | last post by:
Here is a report I've written about a printing problem that is being experienced by a particular company for whom I had developed a A97 system. After upgrading to Win XP and AXP, some printing...
18
by: Ian Stanley | last post by:
Hi, Continuing my strcat segmentation fault posting- I have a problem which occurs when appending two sting literals using strcat. I have tried to fix it by writing my own function that does the...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.