1. ## C programming help please!

I just now got thrown into visual studio and told to make a basic(simple) program even though I don't know anything about the language or syntax, no help was given relating to the assignment, and he answers my questions with riddles. The professor won't tell me if we're correct until after the assignment is turned in. So I'm asking for the mercy of someone that will give me a quick run-through of how to do this program.

This is the exact assignment from the professor:

Problem to be solved:

Input from the user five numbers. Determine, and print out, the smallest number entered and the second smallest number entered.

Do NOT use loops, which we have not yet discussed.

Example run (bold type is what is entered by the user):

Enter number 1: 15

Enter number 2: 27

Enter number 3: 36

Enter number 4: 12

Enter number 5: 9

The smallest number is: 9

The second smallest number is: 12

Do NOT use loops, which we have not yet discussed.

-----

If anyone could give me a quick run-down, I would be eternally greatful!

2. Originally Posted by brown287
I just now got thrown into visual studio and told to make a basic(simple) program even though I don't know anything about the language or syntax, no help was given relating to the assignment, and he answers my questions with riddles. The professor won't tell me if we're correct until after the assignment is turned in. So I'm asking for the mercy of someone that will give me a quick run-through of how to do this program.

This is the exact assignment from the professor:

Problem to be solved:

Input from the user five numbers. Determine, and print out, the smallest number entered and the second smallest number entered.

Do NOT use loops, which we have not yet discussed.

Example run (bold type is what is entered by the user):

Enter number 1: 15

Enter number 2: 27

Enter number 3: 36

Enter number 4: 12

Enter number 5: 9

The smallest number is: 9

The second smallest number is: 12

Do NOT use loops, which we have not yet discussed.

-----

If anyone could give me a quick run-down, I would be eternally greatful!
1) Get a hold of some good C programming books. Read 'em.
2) Write some code. Compile often, in a stepwise fashion.
3) If you run into problems, feel free to post your *detailed* questions here.
4) Lather, rinse, repeat.

3. The reason for posting here is I don't have time to sit down and read a book before this is due. The process of reading a book to be able to do something can be an answer for anything.

I wrote the flowchart and understand the concept, I just don't understand how to convert the flowchart logic into the syntax of c programming. If I had time to read a book, I wouldn't be asking for a quick walk-through of the given problem.

My detailed problem: In C, how do I turn lowestnumber1 and lowestnumber2 into an output statement saying that it's lower than the other 3 remaining numbers?

Thanks.

4. 1) Create a basic program with the needed headers. I suggest you include:
Code:
```#include <stdio.h>
#include <limits.h>```
2) Create three variables:
Code:
```int smallest = INT_MAX;
int second_smallest = INT_MAX;
int input;```
3) Get a one number at a time from the user using:
Code:
`scanf("%d", &input);`
4) Compare the number you got to the one stored in the variable smallest. If it's not smaller, compare it to second_smallest. Replace the stored number if it's smaller.

5) Repeat steps 3) and 4) five times.

6) Print out the result using printf().

scanf - C++ Reference
printf - C++ Reference

5. Very helpful, thank you!

6. write it out in pseudocode at least and post that here - we can always help you fix your syntax.

7. The reason for posting here is I don't have time to sit down and read a book before this is due.
Then I'd say you have the wrong idea about the purpose of this forum. If what you really want is someone to do this for you, then hire someone. Otherwise, you'll need to do your own research - just like the rest of us...

The process of reading a book to be able to do something can be an answer for anything.
Hmm...you might be onto something there!

I wrote the flowchart and understand the concept, I just don't understand how to convert the flowchart logic into the syntax of c programming. If I had time to read a book, I wouldn't be asking for a quick walk-through of the given problem.

My detailed problem: In C, how do I turn lowestnumber1 and lowestnumber2 into an output statement saying that it's lower than the other 3 remaining numbers?

Thanks.
Okay, so at least make an attempt to write the program. Or haven't you the time to that either?

8. @Sebastiani
Cprogramming.com is a web site designed to help you learn the C or C++ programming languages, and provide you with C and C++ programming language resources.

I just assumed the forums would be the same way. But honestly though, if you took as much time to type out something to get me started, than to put me off, we would be done with this by now.

But thanks to Memloop for actually being a sport and helping someone out.

9. Originally Posted by brown287
I just assumed the forums would be the same way. But honestly though, if you took as much time to type out something to get me started, than to put me off, we would be done with this by now.
One of the differences between you and I is that I don't actually care if you get done or not. That means, you have to make the effort to get started, not me. You didn't post anything useful--I don't see your effort. Why should I do it for you? I already know how. I'm not stuck on it, you are. So you need to be the one putting forth effort at learning, not me.

Quzah.

10. Hello, brown287

Please understand that this forum and others like it are constantly beset by "gimmetehcodezplz" homework-beggars, and to a ridiculous degree.

just a cursory glance of your initial post shows that you have posted the detailed requirements of a homework assignment, but neglected to post any code or pseudocode to indicate you had made an attempt to start working on this on your own.

So without making any personal assumptions, your post format exactly follows the MO of a standard homework-beggar.

Now I'm sorry that you were mis-identified. It does happen occasionally. But consider that while this is your very first experience here, Sebastini in his 10 years and thousands of posts can only refer to the historically overwhelming odds continually turn up in his favor.

perhaps in the future you'll remember to include a code segment showing what you have done so far, and if possible illustrating where exactly you are stuck... then we can avoid all the wasted time and hurt feelings.

11. Honestly a part of what sets a good programmer apart from a mediocre one is how resourceful they are at digging up answers. I mean, you could just google for a basic C program, copy and start modifying it until it does what you need/want. Very little of what you will learn of value will just be handed to you. Discovery is a is a joy in itself.

12. Originally Posted by Sebastiani
1) Get a hold of some good C programming books. Read 'em.
2) Write some code. Compile often, in a stepwise fashion.
3) If you run into problems, feel free to post your *detailed* questions here.
4) Lather, rinse, repeat.
You do realize this is an infinite loop ?!

13. Some people do this in their first post:
1. I have to do this
2. Here is my code
3. Please fix it

That in itself is pretty arrogant and if they even get any replies it is pretty much only to tell them that it doesn't work like that.

What you've done is equally bad:
1. I have to do this
2. Please tell me how / Please do it for me

But I suppose it's a step up from this, which we also get from time to time:
1. Write the following for me

14. Originally Posted by iMalc
Some people do this in their first post:
1. I have to do this
2. Here is my code
3. Please fix it

That in itself is pretty arrogant and if they even get any replies it is pretty much only to tell them that it doesn't work like that.

What you've done is equally bad:
1. I have to do this
2. Please tell me how / Please do it for me

But I suppose it's a step up from this, which we also get from time to time:
1. Write the following for me
Other comical variants:

OP: My program performs X, and now I need to add functionality for Y. Please show me how!
US: Uh...your program doesn't do X.
OP: Okay. My program needs to performs X. Please show me how!

OP: I have written a flight simulation program, but the calculations are coming out wrong! Can someone please edit and fix for me?
US: You forgot to initialize the 'theta' variable.
OP: How do I do that?! Sorry, we haven't covered that in class yet!!! BTW: what is the purpose of the 'theta' variable, anyway?
US: ...so you don't even understand "your" own code???