Code Blocks Info.

Hello. Can someone give me examples of 'some code' that I can practice with 'in' the code blocks ide? I'd like to get a feel for things further of the program.

Is it true that if I start I 'new project' that in a small way there is already a template..that you are forced into using. First you 'title' your new project..go thru the 'wizards'..then you'll eventually be brought to the 'Editor's' screen..where you would then go about using your knowledge of the C++ programming that you need to have learned already to create something.

Hmm..I'll have questions later.
Bye
SC
closed account (3voN6Up4)
Hi there.

What do you mean examples of some code?
Here is some code for a program I made that you can copy and paste into codeblocks and run, it calculates the miles per gallon of a car.

#include <iostream>
using namespace std;

int main()
{
int Gallons;
int Miles;
int MilesPerGallon;
cout << "How many gallons does your car hold? " <<endl;
cin >> Gallons;
cout << "To clarify, your car holds " << Gallons << " gallons of gas." <<endl;
cout << "How many miles can your car travel on a full tank of gas?" <<endl;
cin >> Miles;
cout << "So your car can travel " << Miles << " miles with " << Gallons << " gallons of gasoline?" <<endl;
MilesPerGallon = Miles / Gallons;
cout << "You can travel " << MilesPerGallon << " miles per gallon with your car." <<endl;
return 0;
}

closed account (3voN6Up4)
I've never really made new projects, but if you are new to codeblocks I recommend making a newFile and clicking on C/C++ Source. You will be writing your code in that file.
I've never really made new projects, but if you are new to codeblocks I recommend making a newFile and clicking on C/C++ Source. You will be writing your code in that file.


I recommend one does make a project. It's not hard, and will work a lot better when one does have more than one file. One might as well not use an IDE if they are going to just edit a single file.

1
2
3
4
5
int Gallons;
int Miles;
int MilesPerGallon;
// ......
MilesPerGallon = Miles / Gallons; // integer division - be careful with that !! 


Better to use double type. Always check for division by zero.

Always use code tags: http://www.cplusplus.com/articles/z13hAqkS/
Hello. Hate to ask these questions but I will keep them at a minimum.

When I execute a program quote unquote what is that window that shows up? It looks like
a command prompt window. Is it the 'compiler' window?

Hi,

If you have a console application, the program will open a console. It's a bit like a command prompt window (aka shell) but your program is the command being run, and it allows you to input information, and obviously output info from your program.

One can achieve the same thing by running your program from the command line, instead of from the IDE.

Good Luck !!

Edit: Don't worry about asking questions, that is what we are here for :+) There is a difference between a silly question and question about a basic thing, we all had to start from somewhere. A definition of silly/stupid is doing the same thing over and over, knowing that it is wrong.
Last edited on
Hello. The code blocks 'program' has a 'code blocks' forum section people can go to.
It keeps telling me it needs to confirm my email by sending me an activation code.

I never get it.
In the past I was simply able to log on. Now I can't. Also, I was supposed to wait for adminstrator approval..but it is taking forever..and has never came. Do you know what's the problem..and or what should I do?

Thanks for your responses..since it's getting late where I am the questions will be ending soon
Hi,

Are you sure you put in your email address correctly? Normally when one joins a group, the email should arrive within a few minutes.

I guess you could join again, with a different user name.
Hello. Nothing about this place works. It's an irriatating nightmare. O'h well. I'll adjust.

Still though it wastes a lot of my time..which bugs me..alot.

O'h well.

Good bye and good night
closed account (3voN6Up4)
@TheIdeasMan
I wasn't using code tags so he could simply copy and paste the program and see what it does on his compiler. I copy and paste other code on here so I can mess around with it on my own and figure out what they're doing. Yes I should've used double, but hey it was one of my first programs so I mean... haha. Good enough right?

@spacecadet11
This site works great! Maybe there is a tiny little thing you might be doing wrong which messes everything up. Double check your email! Make sure everything is typed correctly.



closed account (E0p9LyTq)
Lucsofhazard wrote:
I wasn't using code tags so he could simply copy and paste

I can copy and paste tagged code just as easily as non-tagged code. The advantage of tagged code is being to view it for possible errors without having to copy and paste.
closed account (3voN6Up4)
@FurryGuy
Well when I copy and paste code into my compiler (Codeblocks) it seems to copy the line numbers as well. Depending on your compiler that'll happen
closed account (E0p9LyTq)
I can copy/paste quite easily without including the line numbers.

With code-tagged code most simple syntax errors are easier to spot without having to paste it into a compiler/IDE.

Not wanting to use code tags, especially after being ASKED repeatedly to use them, is one quick way to be ignored.

With that all said, I'm moving on to other threads.
Topic archived. No new replies allowed.