Jump to content

  • Log In with Google      Sign In   
  • Create Account


New to programming


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 Savalric   Members   -  Reputation: 157

Like
0Likes
Like

Posted 21 December 2012 - 05:28 PM

I learned how to program in Java my freshman year in high school. However, i didn't continue to learn programming, mainly because I still didn't know what I wanted to do. It's now my freshman year in college (ironic) and I've decided to pick it back up. Right now, i'm reading the tutorials on cprogramming.com and I've gotten the hang of the basics again (cin, cout, strings) and I'm trying to wrap my head around some of these other concepts.

First, what purpose do arrays serve, namely a program with this sort of code:

 

#include <iostream>

using namespace std;
int main()
{
	int x;
    int y;
	int array[8][8];

	for ( x = 0; x < 8; x++ )
	{
		for ( y = 0; y < 8; y++ )
			array[x][y] = x * y;
	}
	cout<<"Array indices:\n";
	for ( x = 0; x < 8; x++ )
	{
		for ( y = 0; y < 8; y++ )
			cout<<"["<<x<<"]["<<y<<"]=" << array[x][y] << " ";
		cout<<"\n";
	}
	cin.get();
}

The final thing that I would ask to you guys is this: what sort of programs should I write for practice? Keep in mind my knowledge is limited as far as syntax goes, but if you guys could give me some ideas, it'd help me practice. Unless theres a topic for that already... So far the only thing I can come up with is a simple choose your own adventure text based game.



Sponsor:

#2 Savalric   Members   -  Reputation: 157

Like
0Likes
Like

Posted 21 December 2012 - 05:30 PM

Also, the guide neglected to mention how exactly to make a program into an .exe. So far, i've been using the extension .cpp in Visual Studo 2010 Ultimate, but I'm not sure how to run the source file as an executable.



#3 minibutmany   Members   -  Reputation: 1582

Like
0Likes
Like

Posted 21 December 2012 - 05:50 PM

what purpose do arrays serve

Arrays allow you to store a large amounts of variables under one name. For example in game programming you could use a two dimensional array to store blocks in a 20 by 20 tile map. Simply use a "for" loop to reference each piece of data with a minimum of code.

in order to make your program into an exe, you need to compile it. Visual studio also has a 'run' and 'debug' button which save and compile before running. Your resulting exe should end up in your bin or debug folder.
Stay gold, Pony Boy.

#4 Morphex   Members   -  Reputation: 298

Like
1Likes
Like

Posted 21 December 2012 - 05:58 PM

If you are using Visual Studio it is already compiling your code to exe.

Check your project folders for a bin folder, it should be there.

 

Other than that, arrays:

Array are just a "bag" of something. for example lets say this, I want to store the name of 100 students.

 

How would you do it?Create 100 variables?

Ok it works. but what If I want to create 1000 students?

 

As you can see it becomes really troublesome to manage, so you create a array of strings in this case.

 

string array[1000]. 

It basically creates space in memory for 1000 strings.

 

To access a value you use array[index] and it returns the value that is stored there.To Save a value you do the same thing, but instead o array[index] = something.

 

Arrays are one of the most useful features in any program language.

 

In your case, this int array[8][8] creates a double indexed array, that means you have 8 positions and each of those positions has 8 more.

So in total you have 64 positions.

 

One example I can give you is, think of it has you have 8 students and each of those students have 8 grades that you need to store.

So each of those students could be simple array that holds grades right?

You could have 8 arrays, but the same as before what if I want 100 students?

You would create a 100 arrays? Why not use a array?

 

That is pretty much what it means.

A double index array is just a array of arrays. You can have in theory any number of arrays like int test[8][8][8][8] depending on your needs ofcourse.

 

 

As your second question, I learned to code by making programs for things that I needed. I needed to calculate vectors for maths class, so I made simple console program to calculate the vectors for me, and so on. Create Programs that are fun to you and at the same time useful, you will be motivated and ideas are everywhere. That is my major advice for you.


Check out my new blog: Morphexe 


#5 0r0d   Members   -  Reputation: 813

Like
1Likes
Like

Posted 21 December 2012 - 06:19 PM

You might want to get a good intro book for C++.



#6 Savalric   Members   -  Reputation: 157

Like
0Likes
Like

Posted 21 December 2012 - 06:20 PM

Thanks guys, you two basically answered everything I needed. I missed the part about indexing values and strings inside of the array, which would make a lot more sense than simply using it as a multiplication chart lol. As for what you said Morphex, I used to make simple programs that would calculate my runescape combat level and max hit in java, but i'm no longer proficient at Java, especially since I only took an intro course.



#7 Savalric   Members   -  Reputation: 157

Like
0Likes
Like

Posted 21 December 2012 - 06:25 PM

You might want to get a good intro book for C++.

The problem I usually find with books and online tutorials is that sure they teach you, but they rarely give you good ideas for practice. They tell you what to make, and then show you how they did it. But then again, I should probably finish all of the tutorials before I start small projects lol I'm only up to command-line arguements. Perhaps I'll come up with another idea by the time I've finished.



#8 0r0d   Members   -  Reputation: 813

Like
0Likes
Like

Posted 21 December 2012 - 06:44 PM

You might want to get a good intro book for C++.

The problem I usually find with books and online tutorials is that sure they teach you, but they rarely give you good ideas for practice. They tell you what to make, and then show you how they did it. But then again, I should probably finish all of the tutorials before I start small projects lol I'm only up to command-line arguements. Perhaps I'll come up with another idea by the time I've finished.

 

Still, a good intro book will teach you a lot of small stuff that you need to know, but might not necessarily get in online tutorials... even things like what the compiler and linker do, how the basic data types work, etc.  You need to learn a lot of little things before you can really put it to use.  This is especially true if you're coming from another language like Java, where some things are inherently very different.



#9 Adrisim   Members   -  Reputation: 109

Like
0Likes
Like

Posted 21 December 2012 - 07:12 PM

Programming is beautiful. Keep posting on any doubt to come and we'll feedback to you as soon as we can. 

Now your questions has been answered, there is no much to say but: keep practicing and learning math! 



#10 nesseggman   Members   -  Reputation: 360

Like
0Likes
Like

Posted 23 December 2012 - 11:53 AM

For an example, the webstie learncpp.com not only has detailed explanations of stuff and even starts from the very basics of programming, but it has 'tests' with programs for you to write for practice at the end of each lesson. There are other sites like this, too. Since you liked writing the program to calculate your Runescape info, you can also try http://projecteuler.net/ ... it's a site with just a bunch of math-based problems that you can solve with programs. They get harder as they go so that you are kinda forced to learn more about programming as you clear them. You make an account on the site and can keep track of which you have completed and stuff, and there's a forum if you need help or want to see how other people solved it. Plus you can use whatever language you want to do it, so you can do Java or C or whatever.

 

Does your college offer programming courses that you could take as electives? (I'm assuming you're not there to study programming, or else you'd be taking them already) You could try taking those courses for your math requirement or something, or just for fun. Or if you can't take them for some reason, try asking one of the instructors if you could have a copy of the syllabus with descriptions of the lab assignments (or ask a student taking the courses). Then you could try following along with whatever materials you want, learning the concepts in the order they use in the course, and using the labs as your practice.

 

Another thing is to just think of what you know already and what you're able to program now, and then think of a program you could write that seems just a little outside your reach. Like you might need to learn a new concept or use the ones you know in a way you didn't think of before. Then write that program.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS