hello, i'm newbie here and also in programming world. so I would to request help from pros here. my question is, how to print out number entered in random in ascending order WITHOUT USING ARRAY AND FUNCTION? let say the user key in 4, 56, 31, 90, 11 and the output would be 4, 11, 31, 56, 90. hope anyone would help me.
thank you.
din_hilmi
0
Newbie Poster
Recommended Answers
Jump to Post1) Why ?
2) need compile time variable meaning there will be a fixed amount
of inputs to get3) Need to implement your own sorting method and use it inside main,
so technically it won't be a function. If not then you will need a lot
of …
Jump to PostYes, your if/else is incorrect, only 1 of them gets evaluated.
Jump to PostFive numbers can be ordered 5! or 120 ways. The no-brainer way of writing this code would thus be writing an if statement with 119 "else if" statements, one for each possible ordering. You should be using <= instead of < (what if two elements are the same?). There may …
Jump to Postquite true vernon.. any idea to make it more simpler..?? im not allowed to use array and function to settle this assignment.. uhuh.. >.<
"Simple", "efficient", "correct", and "not tedious" are different concepts. Your "easiest", most brain-dead method is to make 120 "if" statements, not taking advantage of the results …
Jump to PostI wrote something for this and if you want to put in more numbers its really easy (not as easy if you would just use arrays) if you read the code and see what I'm doing.
#include <iostream> using namespace std; int main() { int n1, n2, …
All 29 Replies
mrnutty
761
Senior Poster
samsons17
-4
Posting Whiz in Training
din_hilmi
0
Newbie Poster
samsons17
-4
Posting Whiz in Training
din_hilmi
0
Newbie Poster
mrnutty
761
Senior Poster
samsons17
-4
Posting Whiz in Training
din_hilmi
0
Newbie Poster
samsons17
-4
Posting Whiz in Training
din_hilmi
0
Newbie Poster
din_hilmi
0
Newbie Poster
samsons17
-4
Posting Whiz in Training
VernonDozier
2,218
Posting Expert
Featured Poster
din_hilmi
0
Newbie Poster
mrnutty
761
Senior Poster
din_hilmi
0
Newbie Poster
mrnutty
761
Senior Poster
VernonDozier
2,218
Posting Expert
Featured Poster
kvprajapati
commented:
Excellent advice.
+6
VernonDozier
2,218
Posting Expert
Featured Poster
sfuo
111
Practically a Master Poster
din_hilmi
0
Newbie Poster
mrnutty
761
Senior Poster
VernonDozier
2,218
Posting Expert
Featured Poster
din_hilmi
0
Newbie Poster
solowing
0
Newbie Poster
Maha_6
-3
Newbie Poster
rproffitt
commented:
Please start a new question. Also, if you need it fast, how much are you paying?
-3
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
DGPickett
20
Newbie Poster
Aditya_47
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.