Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: [Example / Listing] It's official I'm going to learn C++ and i got my first ...  (Read 3354 times)

0 Members and 1 Guest are viewing this topic.

gm112

[Example / Listing] It's official I'm going to l...
« on: May 01, 2006, 09:13:31 pm »
Code: [Select]
#include <iostream>

using namespace std;

int main()
{
  int mynumberidiot;
  cout<<"C++\n";
  cout<<"Please enter a number: ";
  cin>> mynumberidiot;
  cin.ignore();
  cout<<"You entered: "<< mynumberidiot <<"\n";
  if (mynumberidiot > 5) {
  cout<<"Rawr!!!!!!!!! BIGGER THAN 5\n";
     cout <<"bye bye bye!!! ^___^\n";
     cin.get();
          }
     else if (mynumberidiot < 5) {
          cout<<"REWR!!!LOWER THAN 5!\n";
          cout<<"BYE! NOW! THIS WAS MADE BY gm112\n";
          cin.get();
          }
          else {             
          cin.get();
          }
  }
lol. just done this a few days ago. I use GCC cuz i perfer it over mingw
« Last Edit: June 22, 2012, 04:55:20 am by gm112 »
Logged

GeekyLink

Re: It's official I'm going to learn C++ and i g...
« Reply #1 on: May 01, 2006, 11:31:20 pm »
Great job for a first project. ;) If you want to program games you should use a windows form, not console. But everyone starts with console. Good luck using c++.
Logged
Re: It's official I'm going to learn C++ and i g...
« Reply #2 on: May 02, 2006, 01:50:01 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 199
that's very good. But what does it do?
Logged
Re: It's official I'm going to learn C++ and i g...
« Reply #3 on: May 02, 2006, 02:33:32 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
It asks the user for a number. If the number is greater than five, it responds with:
Quote
Rawr!!!!!!!!! BIGGER THAN 5
bye bye bye!!! ^___^
if the number is less than five, it responds with:
Quote
REWR!!!LOWER THAN 5!
BYE! NOW! THIS WAS MADE BY  gm112

Not bad for a first thing with C++, I can see you're getting some practice in with if statements.

Great job for a first project. ;) If you want to program games you should use a windows form, not console. But everyone starts with console. Good luck using c++.
NO. NO. NO! Do NOT suggest something like this to a beginner. He must FIRST learn to use functions with console-based C++ programming. Then, when he's managed to get the hang of a decent amount of C++, and THEN, when he's comfortable with functions, pointers, arrays, etc, and ONLY then, should he move on to attempting to learn the Win32 API. Hell, I myself have found little use for the Windows API with games programming (I use IRRLicht game library, though), so he need not worry much about the Win API unless he's working directly with DirectX (and even then you dont need to worry about much asside from creating the windows and setting them up...)
« Last Edit: June 22, 2012, 06:22:19 am by gm112 »
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: It's official I'm going to learn C++ and i g...
« Reply #4 on: May 02, 2006, 02:34:00 pm »
  • The Broken King
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1259
w00t, it's all C++ 6.0 style ~_~
Logged
  • Broken Kings [Temp Site]
Re: It's official I'm going to learn C++ and i g...
« Reply #5 on: May 03, 2006, 03:54:47 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 4588
Nice first job. Reminds me of when i first opened up my compiler box =) (13th BDay, wow...)
Logged
the a o d c
Re: It\\\'s official I\\\'m going to learn C++ a...
« Reply #6 on: May 05, 2006, 06:12:27 pm »
  • Doesn't afraid of anything
  • *
  • Reputation: +42/-0
  • Offline Offline
  • Gender: Male
  • Posts: 7002
looks good to me =)

I am now bored and i\\\'m going to write some random program...probably won\\\'t work since i\\\'m out of practice and I just got back from running the track in gym and my typing is sloppy..

Code: [Select]
#include <iostream>

using namespace std;

int DoWork (short int Ma, short int Va, short int Mb, short int Vb)
{

cout << \\\"Ooh fun, lets find the value of Vb, which is the volume of the base!!!YAY!!!!\\\\n\\\";
cout << \\\"Enter Ma, molarity of the acid\\\\n\\\";
cin >> Ma;
cout << \\\"Enter Va, volume of the acid, in mL\\\\n\\\";
cin >> Va;
cout << \\\"Enter Mb, molarity of the base.\\\\n\\\";
cin >> Mb;
cout << \\\"Working...\\\\n\\\";

Ma *=Va;
Ma /=Mb;

cout << \\\"Volume of the base is\\\"<< Ma <<\\\" mL\\\"n;
}


 
int main()
{
DoWork(Ma, Va, Mb, Vb);
system (\\\"pause\\\");
}

Again, not sure if it will work and I can\\\'t test it now as i\\\'m in graphic design and i\\\'m compilerless >.<
« Last Edit: May 05, 2006, 06:20:17 pm by MasterGohan Zero »
Logged



i love big weenies and i cannot lie

Antidote

>.>
Re: It's official I'm going to learn C++ and i g...
« Reply #7 on: May 08, 2006, 08:51:36 pm »
  • In all seriousness who's serious?
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1485
Why oh why did you use system("pause");
that is the dumbest thing to use even I as a newb know that -_-
Logged
  • Axiomatic Data Laboratories
Re: It's official I'm going to learn C++ and i g...
« Reply #8 on: May 08, 2006, 11:31:20 pm »
  • You don't know me.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 234
*gasp* YOU SKIPPED HELLO WORLD!

Anyways, yah, good program. Not that I should really say that since that's about where I'm at so I would be saying every program I make is good. *is overthinking*

And what is so wrong with system pause? [/showing of C++ newbness]
Logged


No one located in this area of the internet remembers me.
Re: It's official I'm going to learn C++ and i g...
« Reply #9 on: May 09, 2006, 01:25:47 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 221
*gasp* YOU SKIPPED HELLO WORLD!

XD Yeah, 'Hello world' is synonymous with 'First program' lol
Logged
Re: It's official I'm going to learn C++ and i g...
« Reply #10 on: May 10, 2006, 12:11:53 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 4588
cin.get(); is better than system("pause");. System pause throws a message out. Cin.Get just waits, and you can add a cunstom message ^_^.
Logged
the a o d c
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.2 seconds with 56 queries.