Slinky Posted March 5, 2008 Author Report Share Posted March 5, 2008 (edited) /** Lab-5: lab5-3.cpp : Prime numbers *Author: -(Replace this with your name here) * Date: (replace this with today’s date) *********************************************************/ #include <iostream> #include <string> #include <iomanip> using namespace std; int a, b, c; int main () { const int NUMBER_OF_PRIMES = 25; const int NUMBER_OF_PRIMES_PER_LINE = 5; int count = 0; // for counting the prime numbers int number = 2; // starting number for prime number checking cout << "The first 25 prime numbers are: " << endl; int x = 1; cout << endl; for (a = 1; a <= 97; a++) { for (b = 2; b < a; b++) { if ((a%b) == 0) c = 0; } if (c != 0) { cout << setw(5) << a; if(x == 5) { cout << endl; x=0; } x=x+1; } c=1; } return 0; } some of the shit in there is pointless and doesnt need to be in there. im just too lazy to take it out. Edited March 5, 2008 by Slinky Quote DD M4 Rockford Fosgate P500-4 SoundQubed HDC415 w carbon fiber cap 2 Rockford Fosagate T1675-S XS Power D3400 Under Hood XS Power D5100 in rear Michael Singer 200A Alt Build Log: http://www.stevemeadedesigns.com/board/topic/153901-2012-veloster-update-842013-wall-build-4-15s/ Link to comment Share on other sites More sharing options...
Dale Posted March 25, 2008 Report Share Posted March 25, 2008 i remember my days of C++ ... so much fun Quote Link to comment Share on other sites More sharing options...
Slinky Posted March 25, 2008 Author Report Share Posted March 25, 2008 i remember my days of C++ ... so much fun man i hate it. but im sticking with computer science so ill just have to wait it out. Quote DD M4 Rockford Fosgate P500-4 SoundQubed HDC415 w carbon fiber cap 2 Rockford Fosagate T1675-S XS Power D3400 Under Hood XS Power D5100 in rear Michael Singer 200A Alt Build Log: http://www.stevemeadedesigns.com/board/topic/153901-2012-veloster-update-842013-wall-build-4-15s/ Link to comment Share on other sites More sharing options...
Shyne151 Posted March 25, 2008 Report Share Posted March 25, 2008 man i hate it. but im sticking with computer science so ill just have to wait it out. C++ is nothing wait until you get into databases, assembly, and more object oriented programming... not to mention math Glad I'm done next spring. Quote -Installer for Duke's Car Stereo 2000 Pontiac Grand Prix - Ported Eaton M90 S/C, 3.5" pulley, XS Power Headers, 1.9 Rockers, FWI, Poly Motor Mounts, Custom Tune. RF T1000-1bdCP and T400-4 Boston Acoustics SPG 555 Kenwood eXcelon 995 RF Punch 6.5" components and MB Quart Premium 6x9"s Powermaster Alternator, YellowTop D34, Vmax CT1000 Link to comment Share on other sites More sharing options...
Slinky Posted March 25, 2008 Author Report Share Posted March 25, 2008 C++ is nothing wait until you get into databases, assembly, and more object oriented programming... not to mention math Glad I'm done next spring. well it sounds like i have a lot to look forward to then. Quote DD M4 Rockford Fosgate P500-4 SoundQubed HDC415 w carbon fiber cap 2 Rockford Fosagate T1675-S XS Power D3400 Under Hood XS Power D5100 in rear Michael Singer 200A Alt Build Log: http://www.stevemeadedesigns.com/board/topic/153901-2012-veloster-update-842013-wall-build-4-15s/ Link to comment Share on other sites More sharing options...
sshere Posted March 25, 2008 Report Share Posted March 25, 2008 Welcome to the code world. Quote Link to comment Share on other sites More sharing options...
Shyne151 Posted March 25, 2008 Report Share Posted March 25, 2008 well it sounds like i have a lot to look forward to then. Truthfully once you learn C++ you'll be fine with most other languages. I picked up VB, Java, php, and javascript very easy after learning C++. Alot of schools are starting off with Java now instead of C++, idk I learned C++ first then java... and if I had to do it again I don't think I'd change anything. My only words of advice... always plan beore you start programming rather it be an ns chart, flow chart, or whatever. It's a lot easier to follow your ideas/functions than trying to do it all in your head. And believe me they start to get complicated Quote -Installer for Duke's Car Stereo 2000 Pontiac Grand Prix - Ported Eaton M90 S/C, 3.5" pulley, XS Power Headers, 1.9 Rockers, FWI, Poly Motor Mounts, Custom Tune. RF T1000-1bdCP and T400-4 Boston Acoustics SPG 555 Kenwood eXcelon 995 RF Punch 6.5" components and MB Quart Premium 6x9"s Powermaster Alternator, YellowTop D34, Vmax CT1000 Link to comment Share on other sites More sharing options...
Slinky Posted March 25, 2008 Author Report Share Posted March 25, 2008 Truthfully once you learn C++ you'll be fine with most other languages. I picked up VB, Java, php, and javascript very easy after learning C++. Alot of schools are starting off with Java now instead of C++, idk I learned C++ first then java... and if I had to do it again I don't think I'd change anything.My only words of advice... always plan beore you start programming rather it be an ns chart, flow chart, or whatever. It's a lot easier to follow your ideas/functions than trying to do it all in your head. And believe me they start to get complicated yeah my school does C++ first too. my teacher tells us we should write the program ideas down on paper first and then try and type it out. i usually just do it in my head but when it gets more complicating im gonna have to do something like you said. Quote DD M4 Rockford Fosgate P500-4 SoundQubed HDC415 w carbon fiber cap 2 Rockford Fosagate T1675-S XS Power D3400 Under Hood XS Power D5100 in rear Michael Singer 200A Alt Build Log: http://www.stevemeadedesigns.com/board/topic/153901-2012-veloster-update-842013-wall-build-4-15s/ Link to comment Share on other sites More sharing options...
Shyne151 Posted March 25, 2008 Report Share Posted March 25, 2008 yeah my school does C++ first too. my teacher tells us we should write the program ideas down on paper first and then try and type it out. i usually just do it in my head but when it gets more complicating im gonna have to do something like you said. werd like most of our programming assignments in 116 and 216(intro and advanced programming) were programs that processed a data file of like student grades... sometimes upwards of a couple hundred records... when you have to have functions that determine the high score, lowest score, average, letter grade, rank, pass/fail, etc... that's when me head started to hurt and I started writing things down. Quote -Installer for Duke's Car Stereo 2000 Pontiac Grand Prix - Ported Eaton M90 S/C, 3.5" pulley, XS Power Headers, 1.9 Rockers, FWI, Poly Motor Mounts, Custom Tune. RF T1000-1bdCP and T400-4 Boston Acoustics SPG 555 Kenwood eXcelon 995 RF Punch 6.5" components and MB Quart Premium 6x9"s Powermaster Alternator, YellowTop D34, Vmax CT1000 Link to comment Share on other sites More sharing options...
Slinky Posted March 25, 2008 Author Report Share Posted March 25, 2008 werd like most of our programming assignments in 116 and 216(intro and advanced programming) were programs that processed a data file of like student grades... sometimes upwards of a couple hundred records... when you have to have functions that determine the high score, lowest score, average, letter grade, rank, pass/fail, etc... that's when me head started to hurt and I started writing things down. yeah that does sound like its got a lot of stuff involved. in my class last week we went over arrays and now we're going of streams Quote DD M4 Rockford Fosgate P500-4 SoundQubed HDC415 w carbon fiber cap 2 Rockford Fosagate T1675-S XS Power D3400 Under Hood XS Power D5100 in rear Michael Singer 200A Alt Build Log: http://www.stevemeadedesigns.com/board/topic/153901-2012-veloster-update-842013-wall-build-4-15s/ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.