I go 1st year as computer engineer, and what i struggle with is figuring out how to solve problems at school. I understand programming, but when it comes to assignments at, i have no idea what to do. Does anyone have any tips or ideas on how to go forward to solve problems? This might sound stupid but.. :P
I can only offer what I (try to) do, so take this as my opinion and nothing more.
I usually like to try and break problems down into smaller sub-problems. These sup-problems often correspond to steps that need to be taken in order to solve the problem (think of baking, do you just grab a bunch of ingredients and mix them all in one dish? Sometimes it helps to mix all the dry ingredients in one bowl and the all wet ingredients in another, then mix then all together). Of course, sometimes you will break the problem into steps, but those steps need to be broken down further, so just keep breaking everything down until you are confident that you can easily turn each step into code (keep in mind that one step doesn't necessarily have to equate to one line of code; a step can be a bunch of code that is self-telling [to some degree]).
Sometimes this is easy to do in your head, sometimes you might want to take ten minutes and throw down some comments at the beginning of the source file (or functions) outlining the steps. Other times you may need to get pissed off at the stupid thing and grab a pencil and a pad of paper and make some notes.
Again, this is just my opinion and it is what works for me,
Program design is all about breaking down a big problem into smaller parts. A lot of beginners seem to have a hard time with that. They see a problem and are overwhelmed and have no idea how to solve it.
Rather than trying to solve the problem as a whole... break the problem into smaller pieces and try to tackle each one individually.
It's hard to show how to do this without having an example. If you have a problem that's giving you trouble, you can post it and we can probably show you how to break it down.
Here's another thread where I helped someone else with this:
It also helps to program the question step by step following the instructions you are given. You will find that most problems in computer science have already been solved by somebody else. And usually, it is someone who has solved the problem that will give you the same problem to solve. One thing this person will usually do (if they are not careful) is to describe the problem to you by following the logic needed to solve the same problem. So if you are able to follow their instructions step by step, you will find you have solved the problem by the time they finish talking.
I will now follow an example to demonstrate this to you:
Write a program to input a series of 12 integers from the keyboard and store them in a one-dimensional array, x[12], then displayed them on the computer screen in reverse order.
Step by step: Write a program
1 2 3 4
int main()
{
return 0;
}
inputstore a series of 12 integers from the keyboarduserand them in a one-dimensional array, x[12]
1 2 3 4 5 6 7 8 9 10
#include <iostream> // we will need to interact with userint main()
{
int x[12]; // store numbers in one-dimensional-arrayfor (int i = 0; i < 12; i++) // make life simpler, use a for-loop
{
std::cin >> x[i];
}
return 0;
}
then displayed them on the computer screento the user in reverse order
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
int main()
{
int x[12];
for (int i = 0; i < 12; i++)
{
std::cin >> x[i];
}
for (int i = 11; i >= 0; i--) // start in reverse order
{
std::cout << x[i] << " "; // display to user
}
return 0;
}
Every problem has a algorithm to solve it with. There 10 times as many problems as there are algorithms. With this in mind, you will find you are able to solve many more problems by learning a few algorithms.
I would suggest getting familiar with the basic concept of C++. Read some books or visit online tutorial sites such as Microsoft Virtual Academy. They have free video tutorials on C++ designed by industry’s leading experts.