![]() |
|
#1
|
|||
|
|||
Difference between c and c++ [was:New to C, I need help!]Hi people,
I am new to programming, and am trying to create a program, but i cant .... Write a program that inputs one five-digit number, separates the number into its individual digits and prints the digits separated from one another by three spaces each.[Hint: use combinations of integer division and modulus.] For example, if the user types in 42193 the program should print: 4 2 1 3 9 ... Looking forward to ur replies...i need it Urgently please Peace....-MX- Last edited by JdS : 12-Mar-2004 at 07:24.
Reason: Please use a better title in your thread
|
|||
|
#2
|
|||
|
|||
New to CHey,
As you may have noticed, if you have read through other posts, this forum is not a do-your-homework-for-you forum, however I can help with specific problems and questions you may have about some code you have at least attempted to write. In terms of the mathematics of your question, the following piece of code may be able to give you some hints: CPP / C++ / C Code:
Best of, Pan Thomakos |
|
#3
|
|||
|
|||
|
hey sup pan?...thanx for your help...anyways...is there any difference between c and c++?
|
|
#4
|
|||
|
|||
C and C++Quote:
Yeah, actually C was developed before C++. C was a "sequential" programming language (i.e. one instruction after another...) Also, C was written to be quite hardware independent, and required some carfeul planning for portability to different systems. Then C++ (then called "C with objects") was developed (approximately 1980), which allowed programmers to create objects (hence object-oriented programming) with data, variables, and functions that could be shared and replicated easily. Objects essentially were reusable software components that modeled real world objects. Today, the most common differences (at a beginner level) between C and C++ deal with file handling and objects. For instance, output in C++ is handled through "cout" and in C it is handled with "fprint". Also, C++ deals more with "class" objects, and C deals with "structs". Most software is written in either C, C++, or a combination of both. Let me know if you have any more questions about these. Best of, Pan Thomakos |
|
#5
|
|||
|
|||
|
Thank alot for the information, yea, actually, i have another question, i found the answer to my previous question, but it doesn't run in Borland C++...y?..i noticed that it uses cout, instead of prinf, is there really alot of difference between the two?, or are they similar?
|
|
#6
|
|||
|
|||
C codeHey,
Here is the C version of the code: CPP / C++ / C Code:
Regards, Pan Thomakos |
|
#7
|
|||
|
|||
|
Thanx alot, now i need you to explain every part of the code you wrote..so i can write my own version ;-)
|
|
#8
|
|||
|
|||
explainingHey,
The explaining part is for you to figure out, so that you can figure out how to solve your problem. The best way to figure out what code does, is to go through it, line by line. Write down the value of each variable, and perform the operations of each line... You can even include your own print statements, after lines, to see how values have changed. Best of luck, Pan Thomakos |
|
#9
|
||||
|
||||
|
Pan,
The idea behind these boards is to help people solve their own programming assignments, not to give them the answers. Please do not post working code that is a solution to their problem. They learn nothing, and you don't get the grade for their assginment. Okay? Thanks. |
|
#10
|
|||
|
|||
Helping and SolvingHey,
Actually, my code is not a solution to the problem, it just demonstrates the use of the modulus and integer division. It prints the digits in reverse order, and the actual process of printing them in the correct order (mathematically) is fairly different. I am sorry if this is considered posting working code, maybe you could clarify the difference between code that simly demonstrates and code that actually solves the problem. Thanks, Pan P.S: Through a very simple internet search I also found similar code in VB, which also explains what modulus and integer division do: http://www.faqts.com/knowledge_base/view.phtml/aid/3095 |
Recent GIDBlog
Vista ?Widgets? on Windows XP by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The