jeffige 0 Newbie Poster

Don't know if this is the right place to ask, but I've tried for hours searching the web, so I gotta come back to a place I know.

I would like to design some simple 2D scrolling game(s) for android and some apps/ games for toddlers. One(s) that I am free to sell if they turn out well enough. I've searched around and have found some drag & drop game designers, but most want a few hundred dollars just to start. That would be fine if I knew what the heck I was doing. I have dabbled in "C" a bit but not enough to feel comfortable with. I've heard "learn Java", "learn python" and so on, and so on. I just don't know where to start. I asked for help before from Daniweb and got good feedback. So, here I am... again.

Thanks for any tips or suggestions.

jeffige 0 Newbie Poster

Thanx Ancient. A small hint would have sufficed. (c bold type). You know all.

Now, how can I wrap the code: i.e
cout << "The average of: " << a << " " << b << " " << c << " " << d << " " << e <<" = " << (a+b+c+d+e)/5 <<endl <<endl <<endl;

so it doesn't span across the whole page????

jeffige 0 Newbie Poster
In relation to another post, I did enroll in the Game Institute.   http://www.gameinstitute.com/

Thanx for the input Thanx for the help "lAmoebal".  It actually is helping more then when I was following along with other tutorials I have tried. Maybe it 's the structure. I still find C++ difficult. for example.

An excersise asks me to write a program that has a user entering five numbers. Then , average thse numbers, and display the result. So, far. So, good. 
But, when the numbers are displayed, ther are grouped together. How do I space the numbers out in the display. [B]Please, give me hints or clues. Or point me in the right direction. TY[/B]


#include <iostream>

using namespace std;

int main()
{
	//Declare variables
	float a, b, c, d, e;

	cout  << "Please enter a number: ";
	cin  >> a ;
	cout  << "Please enter a number: ";
	cin  >> b ;
    cout  << "Please enter a number: ";
	cin  >> c ;
	cout  << "Please enter a number: ";
	cin  >> d ;
    cout  << "Please enter a number: ";
	cin  >> e ;


	cout << "The average of: " << a << b << c << d << e <<" = " << (a+b+c+d+e)/5 <<endl <<endl <<endl;
		
		
		
}
jeffige 0 Newbie Poster

Got it!
TY vijayan121.

Man this C++ stuff is EZ...:sweat:

jeffige 0 Newbie Poster

AWESOME! Ty wolfpack. I guess I could have figured that out if I kept at it for another few months.

Can you answer another noob ? for me...

In the line of code:

cout << n1 << " + " <<  n2 << " = " << n1+n2  <<endl;

why do you have to 'state' the <<n1+n2 if it has already been 'stated' before in that line?

thanx

jeffige 0 Newbie Poster

I am taking a course on C++ game dev and one of the exercises asks me to write a program that:

asks the user to input two numbers.
compute those numbers, +, -, *, %.
and then display the results.

It took me forever and a minute, but I got it. But how do I get the command window to display the number the user inputs instead of the n1 and n2?
(i.e: 8 + 4 = 12, not n1 + n2 = 12)

#include <iostream>
#include <string>

using namespace std;

int main()
{
   int n1;
   int n2;

   cout << "please enter a number:       ";
   cin >> n1;
   cout << "please enter another number: ";
   cin >> n2;

   cout << "n1+ n2 = "<< n1+n2  <<endl;
   cout << "n1 - n2 = " << n1-n2 <<endl;
   cout << "n1 * n2 = " << n1*n2 <<endl;
   cout << "n1 % n2 = " << n1%n2 <<endl;

}
jeffige 0 Newbie Poster

I was browsing around the web looking for C++ tutorials and I found The Game Institute. I have been thinking about taking their course-
C++ Programming for Game Developers - Module I - Introduction to C++ Programming Basics.

Has anyone heard any info about this course?

jeffige 0 Newbie Poster

I don't see any reason either. I am dumbfounded. I am entering the code exactly as the tutorial shows. Everything is fine upto the dang average.

Again, I am entering the code as follows, including the

cin.get();
return 0;

/* This program calculates the average age of a class of five students after prompting the user to enter the age of each student. */
#include <iostream.h>
main ()
{
// declaration of variables, the age will be in whole numbers
int age1, age2, age3, age4, age5;
int TotalAge, AverageAge;
// take ages of the students from the user
  cout << "Please enter the age of student 1: ";
  cin >> age1; 
  cout << "Please enter the age of student 2: ";
  cin >> age2;
  cout << "Please enter the age of student 3: ";
  cin >> age3;
  cout << "Please enter the age of student 4: ";
  cin >> age4;
  cout << "Please enter the age of student 5: ";
  cin >> age5; // calculate the total age and average age
TotalAge = age1 + age2 + age3 + age4 + age5;
AverageAge = TotalAge / 5;
// Display the result ( average age )
cout << "Average age of class is: " << AverageAge;
cin.get(); 
return 0;
}

If possible AncientDragon, could you check out the tutorial?

http://howtoprogramc.googlepages.com/expressions.htm

Ty for your reply...

jeffige 0 Newbie Poster

That was actually the first thing I tried after it wouldn't give me the average. Sorry, I guess I should've mentioned that.

jeffige 0 Newbie Poster

Following along a tutorial I entered code for a person to enter the age of five students.
Then, the program is supposed to divide the five ages and display the result.

It allows me to enter the ages, but as soon as I hit enter after inputting the fifth age, the window closes.

I have looked over the code, can't find anything wrong. Can someone help please.

/* This program calculates the average age of a class of
five students after prompting the user to enter the age 
of each student*/

#include <iostream.h>
main()
{
// declaration of variables, the age will be in whole numbers//
int age1, age2, age3, age4, age5;
int TotalAge, AverageAge;
//Take ages of the students from the user//
       cout << "Please enter the age of student 1:";
       cin >> age1;
       cout << "Please enter the age of student 2:";
       cin >> age2;
       cout <<"Please enter the age of student 3:";
       cin >> age3;
       cout <<"Please enter the age of student 4:";
       cin >> age4;
       cout << "Please enter the age of student 5:";
       cin >> age5;
//Calculate the total age and average age//
   TotalAge = age1 + age2 + age3 + age4 + age5;
   AverageAge = TotalAge / 5;
   //Display the result (average age)//
   cout << "Average age of class is:" <<AverageAge;
}

Also, how can someone (namely myself) tell if the code is written in C or C++?
Any pointers on the look, ie: the structure of my coding.

jeffige 0 Newbie Poster

Sorry, for taking so long on replying, was gone for a bit.

I don't know (can't) tell you what's up. I tried a different tutorial. One that seems a bit more "EDUCATIONAL". I have not done anything different, exept learned a tad more, and it has not happened again.


Ty for all of your reply's.

jeffige 0 Newbie Poster

Sorry, for taking so long on replying, was gone for a bit.

I will use the cin.get();

I just like entering the code much better than using the command window.

Thank you for all of your reply's. This C stuff is way cooler than...:)

jeffige 0 Newbie Poster

So, the file extensions are .cpp. Would that make a huge difference if I am programming in C?

If so, can I save the files with .c in DevC++?

TY for your reply.

jeffige 0 Newbie Poster

Following along a C tutorial, I entered this code. When I compile and run, it aks for my age, which I enter. But it doesn't display any of the 'if' or 'else' statements. So I hit enter and the window closes. Is there a trick or am I entering the code wrong?

#include <stdio.h>

int main()        
{
    int age;      
    
    printf( "Please enter your age" );  
    scanf ("%d", &age);   
    if (age < 100) {       
    printf ("You are pretty young!\n");    
    }
    else if (age == 100 ) {              
    printf ( "You are old \n");
}
else {
     printf ( "You are really old \n");    
}
return 0;
}
jeffige 0 Newbie Poster

Ty for your reply.

After I write the code:

// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

I hit f9.
The compile progress window opens. After a second or two, instead of the Dos window
opening, I get that [*]cstddef file opening.

jeffige 0 Newbie Poster

I have been following a C tutorial and using DevC++. When I write this code:

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

and try to compile and run, I get this file popping up...


[*] cstddef


// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.

It continues to talk about the GNU General Public License for a few paragraphs.
And then it reads...

/** @file cstddef
* This is a Standard C++ Library file. You should @c #include this file
* in your programs, rather than any of the "*.h" implementation files.
*
* This is the C++ version of the Standard C Library header @c stddef.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std.

Then it has this code at the bottom?

#ifndef _CPP_CSTDDEF
#define _CPP_CSTDDEF 1

#pragma GCC system_header

#include <stddef.h>

namespace std 
{
  using ::ptrdiff_t;
  using ::size_t;
}

#endif

I have searched for an …

jeffige 0 Newbie Poster

Is there any way to get rid of the "Press any key to continue" in the Dos window.:-/

I am using DevC++ ver. 4.9.8 It gets alittle annoying after awhile.

And yes, I am new to programming.

jeffige 0 Newbie Poster

ty jbennet. You and ancient dragon have helped
me get going. Woohoo!

jeffige 0 Newbie Poster

Yes, thank you again, sir.

I have been trying to get things together on my own for a few weeks. Getting the compiler running and all. I guess I got lazy and couldn't wait to actually start with the programming.

And I promise to take my time (and stop wasting others') and actually look through posts, threads and do a Google search.

Thank you again, for taking the time to stop and answer a newbies ?

jeffige 0 Newbie Poster

O.k. Right now, I am banging my head against the table. There is this cool thing call
Google Search. Way cool.

For others who might not be as new as myself: http://www.fredosaurus.com/notes-cpp/ide/devcpp.html

jeffige 0 Newbie Poster

I just started using DevC++ (ty Ancient Dragon) to learn C/C++. I am starting with the basic Hello World! The online tutorial I am following (which seems pretty good to me, but what do I know...yet) does not express how to check my work.

I remember seeing a C tutorial that had an example of how to keep the DOS? window open to see if the code you are writing is correct. Do I even need to keep it open. Right now, all
I am getting is the flashing window.

I have written the code as follows...

//my first c++ program

#include <iostream>
using namespace std;

int main ()
{
 cout <<"Hello World!";
 return 0;
 }

I then click the "compile and run" button.

Thank you for any direction...

jeffige 0 Newbie Poster

HELLO WORLD! I'm sorry. I couldn't help myself.

My name is jeff. I am 16 years old, again... for the 22nd time.
I really don't live anywhere. I work for a company that travels around the U.S
11 months out of the year. I live on the worlds longest privately owned train. Along, with about 200 or so other people. No. Really.

I am married, and we have a nine year old daughter. And another on the way. Due in august. My family also lives with me on the train.

Am I a computer geek. I don't know really. I love being on the pc for hours a day. I love learning about things that have to do with the pc.
I have learned a little bit of... AUTOCAD...PHOTOSHOP...MATHEMATICS IN GAME DESIGN...3ds max6, forgetaboutit...AND YES... C and C++...

A guy by the name of DON was traveling with us for about 8 months. During those eight months he set up my laptop with the BORLAND compiler. And he started to teach me C.

"C came before C++, so learn C first," he said.
I was dumbfounded that I could actually learn this. I have always wanted to make my own programs. O.k. I would dream of it.

He taught me for only a few weeks. The company that I work for doesn't leave alot of time for other things. He wanted to teach me more, and I wanted to learn …

jeffige 0 Newbie Poster

First let me say sorry to all the experts out there. I just don't know where else to turn. A friend of mine who was teaching me c, even set up borlands compiler for me on my laptop, quit the tour that I am on. My old laptop crashed I have read all I can on installing and using the compiler. I just can't get it.

I want to learn c++ but am not able to actually go to school right now since my job keeps me on tour 11 months out of the year. I keep getting the window that says:

Microsoft<R> Windows DOS
<c>copyright Microsoft Corp 1990-2001

C:Users\Masters~1>

I want to learn c++ so bad I'm losing my hair. And my wife keeps giving me those funny looks. Thanks for any help any one can give...