| View previous topic :: View next topic |
| Author |
Message |
Travis13 Expert Cheater
Reputation: 0
Joined: 17 Feb 2007 Posts: 199
|
Posted: Sat Apr 05, 2008 6:58 pm Post subject: Practicing/Showing off my C++ skills |
|
|
hey guys here are some of my c++ projects after 2 days of learning......i got amost all of it from a tutorial and stuff but i actually know wat it means and stuff now.......this is here just to prove that ppl like me who always used to leech stuff are actually trying to learn now...i am NOT going to give up and just take a look at it before this topic gets moved
i know this is pure randomness so meh w/e deal w/ it
| Code: | #include<iostream>
using namespace std;
int main()
{
cout << "This is my program " << endl;
system("pause");
return 0;
} |
and a longer one
| Code: | #include<iostream>
using namespace std;
int main(void)
{
system("TITLE Travis' Calculator");
system("COLOR 4F");
char cChar;
double dfirstnumber;
double dsecondnumber;
char cDoagain;
do
{
system("CLS");
cout << "please enter the first number that you would like to use" << endl;
cin >> dfirstnumber;
cout << "please enter the operation that you would like to complete" << " (+,-,* or /)" << endl;
cin >> cChar;
cout << "please enter the second number you would like to use" << endl;
cin >> dsecondnumber;
switch (cChar)
{
case '+':
cout << "The answer is: " << dfirstnumber << " + " << dsecondnumber << " = " << (dfirstnumber + dsecondnumber) << endl;
break;
case '-':
cout << "The answer is: " << dfirstnumber << " - " << dsecondnumber << " = " << (dfirstnumber - dsecondnumber) << endl;
break;
case '*':
cout << "The answer is: " << dfirstnumber << " * " << dsecondnumber << " = " << (dfirstnumber * dsecondnumber) << endl;
break;
case 'x':
cout << "The answer is: " << dfirstnumber << " x " << dsecondnumber << " = " << (dfirstnumber * dsecondnumber) << endl;
break;
case 'X':
cout << "The answer is: " << dfirstnumber << " X " << dsecondnumber << " = " << (dfirstnumber * dsecondnumber) << endl;
break;
case '/':
if(dsecondnumber == 0){
cout << "That is an invalid operation" << endl;
}else{
cout << "The answer is: " << dfirstnumber << " + " << dsecondnumber << " = " << (dfirstnumber + dsecondnumber) << endl;
}
break;
default:
cout << "That is an invalid operation" << endl;
break;
}
cout << "Would you like to start again? (y or n)" << endl;
cin >> cDoagain;
}while (cDoagain == 'Y' || cDoagain == 'y');
system ("PAUSE");
return 0;
} |
|
|
| Back to top |
|
 |
Karakawe I post too much
Reputation: 3
Joined: 17 Apr 2007 Posts: 3899
|
Posted: Sat Apr 05, 2008 7:10 pm Post subject: |
|
|
Have you tried to compile this?
Borland gives two errors :
1. Line 2 - Namespace name expected
2. Line 7 - Call to undefined function 'system' in function main()
Now fix it!
And keep up the good work.
C++ wins.
|
|
| Back to top |
|
 |
Travis13 Expert Cheater
Reputation: 0
Joined: 17 Feb 2007 Posts: 199
|
Posted: Sat Apr 05, 2008 7:14 pm Post subject: |
|
|
lol thanks for replying....and yes i have compiled it with dev-c++............GREAT program i like it lots, i would use visual c++ from microsoft but my computer gets an error trying to install .net 3.5 framework (NO CLUE WHY IF U KNOW WHY TELL ME ANYONE )
anyways yeah i got no errors...after fixing it a million times and its in an exe now and it works great
btw ppl if u need good tutorials on learning c++ heres a good guy on youtube that gives good tutorials.....DONT RUSH THROUGH THEM....understand EVERYTHING before u go on to video 2 et cetra.
http://youtube.com/watch?v=nziy2_U5JQI
|
|
| Back to top |
|
 |
Karakawe I post too much
Reputation: 3
Joined: 17 Apr 2007 Posts: 3899
|
Posted: Sat Apr 05, 2008 7:15 pm Post subject: |
|
|
Okay, might be slight differences between the compilers.
I used to use dev-cpp. Nice program.
Edit: Their site is this?
Last edited by Karakawe on Sat Apr 05, 2008 7:17 pm; edited 1 time in total |
|
| Back to top |
|
 |
Travis13 Expert Cheater
Reputation: 0
Joined: 17 Feb 2007 Posts: 199
|
Posted: Sat Apr 05, 2008 7:17 pm Post subject: |
|
|
| yeah, anyways u know how to make a gui? i know delphi is all about buttons and functionings and everything and i have it downloaded (borland delphi 7) but how how do u use it with c++ compiled sources?
|
|
| Back to top |
|
 |
Karakawe I post too much
Reputation: 3
Joined: 17 Apr 2007 Posts: 3899
|
Posted: Sat Apr 05, 2008 7:19 pm Post subject: |
|
|
You've got me there. I've only really worked in depth with C++. I like controlling everything in my programs.
So, I'm not really sure. You'd probably have to start getting into Delphi more to figure out how.
|
|
| Back to top |
|
 |
Travis13 Expert Cheater
Reputation: 0
Joined: 17 Feb 2007 Posts: 199
|
Posted: Sat Apr 05, 2008 7:23 pm Post subject: |
|
|
| Karakawe wrote: | You've got me there. I've only really worked in depth with C++. I like controlling everything in my programs.
So, I'm not really sure. You'd probably have to start getting into Delphi more to figure out how. |
well yeah if i ever wanted to release something i would want to write it in c++ but i would like some kind of design to it, not just a black box or maybe change the colour of foreground and backround.....meh ill search around
p.s. trade rep?
|
|
| Back to top |
|
 |
sinsgift Cheater
Reputation: -1
Joined: 16 Aug 2007 Posts: 43 Location: behind you
|
Posted: Sat Apr 05, 2008 7:58 pm Post subject: |
|
|
wrong section
_________________
Watch out im out to get you...
 |
|
| Back to top |
|
 |
Drops Advanced Cheater
Reputation: 0
Joined: 22 Feb 2008 Posts: 62
|
Posted: Sat Apr 05, 2008 8:03 pm Post subject: |
|
|
| I wouldn't use anything from system...I remember when I was learning the basics people were scolded for using that...especially to just pause the program from shutting off. Use cin.ignore() and cin.get().
|
|
| Back to top |
|
 |
TheZaw Valve mod
Reputation: 0
Joined: 01 Mar 2008 Posts: 1061 Location: Learning C++
|
Posted: Sat Apr 05, 2008 8:21 pm Post subject: |
|
|
Heya, im learning C++ too! Compile this! fully commented and stuff, not complete yet. Gotta finish the math part of it.
| Code: | #include <iostream>
using namespace std;
int goal, current, buy, sell;//declaring integers for use
int profitper, profit, d, e, f; //integers used in the math part
int itemsper;
int remainder;//these integers will be thrown away later, just needed to store temporary values
int main(){//main part of program
cout<<"Enter current money available for merchenting: ";
cin>>current;//gets current money for merchenting. Cout stands for console (keyboard) out. Cin stands for console in.
cin.ignore();//ignores enter, so cin.get doesn't trigger.
cout<<"Enter goal for total cash at end of merchenting: ";
cin>>goal;//Gets Goal for cash
cin.get();
sorry4screweingGoodPractice://C++ "joke"
cout<<"How much are you buying the item for: ";
cin>>buy;//gets how much to buy item for
cin.get();
cout<<"How much are you going to sell the item for: ";
cin>>sell;
cin.ignore();
if(buy>sell){
goto sorry4screweingGoodPractice;
}
while (current<goal);{//while current money is less than goal do this
profitper=sell-buy;//gets profit per item
itemsper=current/buy;
remainder=current%buy;//the "%" operator returns the remainder of the divisor
if(remainder){
current=current+1;
}
profit=profitper*itemsper;
cout<<"lol";
}
cout<<"Test";
cin.get();//when finished, press enter to terminate program
}
|
_________________
|
|
| Back to top |
|
 |
Chaosis13 Master Cheater
Reputation: 0
Joined: 14 Aug 2007 Posts: 372
|
Posted: Mon Apr 07, 2008 4:43 pm Post subject: |
|
|
lol... Sorry, I had to say it.
I just hope you stay dedicated(after 2 days), we need more C++ coders.
|
|
| Back to top |
|
 |
Pseudo Xero I post too much
Reputation: 0
Joined: 16 Feb 2007 Posts: 2607
|
Posted: Mon Apr 07, 2008 5:23 pm Post subject: |
|
|
Don't use system("pause").
_________________
| haxory' wrote: | can't VB do anything??
windows is programmed using VB right? correct me if im wrong.
so all things in windows you have like the start menu is a windows form too. |
|
|
| Back to top |
|
 |
WafflesFTW Expert Cheater
Reputation: 0
Joined: 21 Mar 2008 Posts: 131
|
Posted: Mon Apr 07, 2008 6:40 pm Post subject: |
|
|
| Coding GUIs eh.. well that will be in the far future. Focus now on pointers/arrays/classes/objects and master those completely on console apps. Then start to learn the Windows API and how to code GUIs from there. I know its tempting to build a bot, we all feel it, but its much better when you code it efficiently and when you know EVERYTHING about what you are doing.
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Mon Apr 07, 2008 11:37 pm Post subject: |
|
|
| is it natrual that everyone's making a calculater as their 2nd or 3rd program in C/++ ? because i see everyone's doing it (even i did lol)
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Tue Apr 08, 2008 3:46 am Post subject: |
|
|
| Code: | | goto sorry4screweingGoodPractice; |
Not bad practice if you use it right.
|
|
| Back to top |
|
 |
|