Question:
C++ programming Question(no solving involved)?
John S
2009-11-09 10:24:16 UTC
I'm taking an intro to C++ programming course in uni but I'm not able to figure out the thinking process needed to solve the questions...
I understand what the functions do and when I read a solved problem I understand it completely...but when I come to sit and write one on my own I don't know where to start or end!!
Five answers:
2009-11-09 10:40:48 UTC
It's best to think like a computer. Since we know that computers compile code in steps from top to bottom, functions work the same way. It's like making a to-do list. What does the function have to do? Once you figure out what the function needs to do, that means you know what variables it needs. Then you have to ask what's the first step to set the variables? Then the next step to modify the variables. Then the next step to return or finish the variables. That's all there really is to writing functions. Don't try to visualize the whole function at once. Just step by step.
Suman
2009-11-09 10:39:53 UTC
We all face these problems. Dont worry. You need lots of practice there's no shorter way around (unfortunately !)

1stly do a few programs in form of algorithms or flowcharts whichever is comfortable with you. Just write the steps what you think will help in solving a problem.

2ndly dont try to learn a lot of things and apply them together. Follow the elementary program snippets that we find in a standard good book and run them. Gain some confidence to move over to larger tasks.

All programmers go through this face. Take the correct approach and you will be writing better codes than you ever imagined.

All the best! Happy coding !
2009-11-09 10:34:55 UTC
yes I had the same problem before 2/3 years.

You have to read and understand more and more questions.

First try the easier questions.

Then medium.

Then Hard.

You have to compare the questions with each other, then you can understand the basic difference between the programs.

Then you should try to solve the questions practically.

If you don't solve the problems in a computer, you can't tell a program is correct or not.



You have to understand clearly the basics of C++.



thanks
Yanichka
2009-11-09 10:32:51 UTC
That's why you take the course. If you have questions after a day or two of classes, talk to the professor.



P.S. You forgot to ask a question. :)
genie
2016-05-23 05:33:20 UTC
ur program has a bug. setw(int) acts only on the immediately next variable. so u would do it like this: int main () { for(int i=0; i<10000; i++) cout<


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...