demolaynyc
Dec 19 2006, 06:22 PM
Hey, just posting some exercises from Chapter 4 of the old book. CODE /* Chapter 4 Exercise 11a by Albert Villaroman 11-27-06 */
#include <iostream.h>
int main () { cout <<"Enter a non-negative integer: "; int u; cin >>u; while (u<0) { cout <<"Enter non-negative integer: "; cin >>u; }
int potentialPrimes=0, loops=0; for (int f=2; f<u; f++) { if (u%f != 0) { potentialPrimes++; } loops++; } if (potentialPrimes == loops) cout <<"prime" <<endl; else cout <<"not prime" <<endl;
return(0); }
/* Chapter 4 Exercise 11b by Albert Villaroman 11-27-06 */
#include <iostream.h>
int main () { cout <<"Enter starting number: "; int u; cin >>u; while (u<0) { cout <<"Enter a non-negative integer: "; cin >>u; }
cout <<"Enter ending number: "; int e; cin >>e; while (e<0) { cout <<"Enter a non-negative integer: "; cin >>e; } int primesInBetween=0; for (u; u<=e; u++) { int potentialPrimesInLoop = 0, loopsInCurrU = 0; for (int f=2; f<u; f++) { if (u%f != 0) potentialPrimesInLoop++; loopsInCurrU++; } //end for if (potentialPrimesInLoop == loopsInCurrU) primesInBetween++; }//end for
cout <<"Number of primes in range: " <<primesInBetween <<"\n\n"; return(0); }
/* Chapter 4 Exercise 12 by Albert Villaroman 12-5-06 */
#include <iostream.h>
int main() { cout <<"Enter a number: "; int userInt; cin >>userInt; int counter=2; cout <<"Prime factors: "; while (counter <= userInt) { if (userInt%counter == 0) { cout <<counter <<" "; userInt /= counter; } else counter++; } cout <<endl; return(0); }
/* Chapter 4 Exercise 13 by Albert Villaroman 12-5-06 */
#include <iostream.h>
int main() { int user1, user2; cout <<"Enter an integer: "; cin >>user1; while (user1 < 0) { cout <<"Enter a non-negative integer: "; cin >>user1; } cout <<"Enter another integer: "; cin >>user2; while (user2 < 0) { cout <<"Enter a non-negative integer: "; cin >>user2; } int GCD=0; bool stop=false; for (int i=2; (i<user1 || i<user2); i++) { if (user1%i==0 && user2%i==0) GCD = i; }
cout <<"GCD is " <<GCD <<endl; return(0); }
Reply
borlafu
Dec 20 2006, 07:26 PM
Recent Queries:--
c codes for opening files - 98.98 hr back. (1)
-
c programming codes for database - 105.97 hr back. (1)
-
c codes for loop - 116.93 hr back. (1)
-
c prime number codes - 122.08 hr back. (1)
-
free html source codes for registering - 126.47 hr back. (1)
-
free source codes for c - 132.12 hr back. (1)
-
free online source codes for c - 136.05 hr back. (1)
-
c codes for prime numbers - 321.93 hr back. (1)
-
c free exercises in if - else - 348.14 hr back. (1)
Similar Topics
Keywords : source, codes, c
- Question About Opengl Codes.
(0)
Common Ftp Server Error Codes
error codes that you come across (0) QUOTE ~~~~~~~~~COMMON FTP ERROR CODES~~~~~~~~~~ # Description 110 Restart marker reply. In
this case, the text is exact and not left to the particular implementation; it must read: MARK yyyy
= mmmm where yyyy is User-process data stream marker, and mmmm server's equivalent marker (note
the spaces between markers and "="). 120 Service ready in nnn minutes. 125 Data connection already
open; transfer starting. 150 File status okay; about to open data connection. 200 Command okay.
202 Command not implemented, superfluous at this site. 211 System status, or sy....
Make It Impossible To View Page Source
(11) Hi! I was just wondering if it is possible to make username unable to view the page source.. I
know that you can disable right click, but still, they can go to the page source from the navigation
menu on the top of the browser.. if possible, I would really like a code that works on all browsers.
Or if you know different codes that works on different browsers.. Thanks //Feelay....
Test Out Cms And Other Php Stuff
Open-Source CMS (0) If you are looking for a content management system but don't know which one to pick, here is a
site where you can test all of them, in Administrator mode to see which one suits you best.
http://opensourcecms.com/ This site allows you to do whatever you want with a CMS system for
testing purposes. It gives you administrative access to the control panel so you can create/delete
content without messing up something and to see if it is easy enough for you to use. The systems are
wiped out after a predetermined time of 2 hours, so that everything is refreshed again. ....
Tremulous Is A Free And Open Source Team-based First-person Shooter With Real-time Strategy Elements
Test it ! (0) Tremulous is a free and open source team-based first-person shooter with real-time strategy
elements. It was released on March 31, 2006 . Game-play is similar to the Quake II mod Gloom. The
game features two teams, humans and aliens, each with their own strengths and weaknesses. The game
has been downloaded over 800,000 times and was voted "Player's Choice Standalone Game of the
Year" in Mod Database's "Mod of the Year" 2006 competition. Though Tremulous features a similar
theme and game-play to Natural Selection, it is not based on it, nor inspired by it. Develo....
Open Source Social Networking
Social Networking Site Based On drupal (1) I feel that PHP FOX and other commercial social networking scripts are way too costly for any new
social networking site and that adds to the fact that these scripts need to be modified to help the
site stand apart from being a clone of the more established players in the business. I tried using
PHP IZABi ,the script is slick and easy to use ,not to forget its fast but most of the important
addons(modules,themes,hacks) are paid ,hence it doesn't fit the bill. Instead of looking at
stand alone solutions i started using Joomla,being targeted towards everyone,joomla h....
Mp3 Codes For Myspace & Friendster
(0) Hi www.mp3-codes.com offers a free mp3 codes for your myspace and friendster accounts. Check them
out they have tagalog (Philippines) and english music.....
Counter-strike Source The Best!
(2) Wooow after I have seen the preview from the t.v woow i was totally amazed! The graphics are
amazing. I wish i have this one. CS source is better than other versions. Do you agree?....
Codes For Js
Codes For JS i have managed to pick up (5) here is one code i will post another CODE <script LANGUAGE="JavaScript">
<!-- // Use these three variables to set the message, scroll speed and start position var
msg = "Your Message Here" //This is the message that will appear in the status bar. var
delay = 128 //increase to slow down movement var startPos = 130 //increase to move start
position to the right // Don't touch these variables: var timerID = null var timerRunning =
false var pos = 0 // Make it all work Scrollit() function Scrollit(){ ....
100 Open Source Downloads
(6) It’s not the "Top 100", nor does this list contain the "only" 100 open source downloads you should
consider - there’s a big ocean out there, so please keep swimming. But this list does reflect the
growing vitality of the open source ecosystem. It just keeps growing ... and growing ...
http://itmanagement.earthweb.com/osrc/article.php/3689281 ....
Two More Listings Of Free, Open Source Windows Apps For You
(0) Most of these are well-known freebies for Windows, but who knows, you might find a gem.
http://www.teknobites.com/2007/07/19/20-op...s-apps-for-you/
http://www.teknobites.com/2007/09/08/40-fr...s-apps-for-you/ A more comprehensive list -
http://osswin.sourceforge.net/ Also see: http://en.wikipedia.org/wiki/List_of_free_software ....
Quote From Microsoft: "open Source Is Neither An Industry Fad, Nor A Magic Bullet"
(0) Here is an article that talks about the growing number of applications Microsoft is releasing with
open source access. http://www.linuxjournal.com/node/1000260 I remember listening to a recording
of a conference call not very long ago, where a Microsoft employee talked about how Microsoft does
not hate the concept of open source per se, they just have a business problem with the GPL. One of
the readers who posted a comment to the above linked article calls Microsoft "hypocritical, also
ridiculous" for coming up with a way of circumventing GPL called "Shared Source".....
Bittorrent Goes Closed Source
(1) Just found this on digg: http://www.slyck.com/story1566_BitTorrent_...d_Source_Issues My
comments: If this doesn't smell like a backroom deal with the RIAAs and the MPAAs of the world,
I don't know what does. Thoughts? ....
Debian Users, Please Post Your Source List Here
(3) Please copy/paste your /etc/apt/sources.list here.....
Decompile An Exe To Source Code
How to recognize it (10) Hello Friends, I am new on this site. Something about myself, I am Teri, a Software
Developer with 7+ years of experience. Have worked on C++, Vb, .NET, Java & so on. I
have a program's exe file which needs some changes to be done. I understand that I need to
decompile it to translate to source code. But, how can I recognize that the program is written in
which language. Which decompiler should be used. I mean if the prg is written in VB, C++, Java, .net
the respective decompiler should be used. How do I recognize the programming language & whi....
Open Source Vs Proprietary Softwares
Comparative Studay (11) I have recently moved to live in Europe, and I notice a great trend picking up in the subject of
open source systems. it seems to be all about open source systems these days. I am currently
implementing a student/course administration system, and... to be honest, these open source systems
seem to be giving proprietary systems a run for their money. I'm wondering what you people out
there think about open source vs proprietary systems.....
Microsoft Has Basically Declared War On Open Source!
(8) Hey all As a supporter of open source software and a user of Linux, I am angered at Microsuck's
latest actions and lawsuit threats towards Linux Kernel, GUI, OpenOffice.org, and many other open
source applications. All I have to say is, why the wait? Most of the stuff they're COMPLAINING
violates their patents is OLDER or JUST AS OLD as Windows. Also, they're leaving a lot out of
the lawsuits: Linux is based off of UNIX so they would have to then sue the creators and/or users
of UNIX... but wait, it gets better! They would then have to sue Apple because....
A Tutorial For Html Color Codes
(7) HTML Coloring System - RGB Values RGB which stands for Red, Green, Blue. Each can have a value from
0 (none of that color) to 255 (fully that color). The format for RGB is - rgb(RED, GREEN, BLUE),
just like the name implies. Below is an example of RGB in use. Red, Green, and Blue Values:
bgcolor="rgb(255,255,255)" White bgcolor="rgb(255,0,0)" Red bgcolor="rgb(0,255,0)" Green
bgcolor="rgb(0,0,255)" Blue HTML Color Code - Breaking the Code The following table shows how
letters are incorporated into the hexadecimal essentially extending the numbers system to 16 values....
Open-source Dsp
An idea for "open" musicians. (1) The power of computing has been utilized in the music industry for quite a while now... beginning
with the mandatory Cubase installation in every self-respecting studio, and going up to music that
is created solely by a CPU. Music helps us express ourselves, and machines help us create music.
The prices of various types of DSPs (digital signal processors) for guitarists have been sky-high
since the dawning of effects. They will also continue to be expensive because the technology that
enables them ain't cheap. So you're paying quite a lot of money for a GFX-8 wh....
Is There An Open-source Fontographer?
(4) Is there a program out there that is similar in nature and features to Fontographer? I would like
to make my own fonts and edit old ones... however, the software package that contains Fontographer
is much too expensive for my budget... If there is an open source version (any kind of freeware,
actually) of this program, please provide me with the link. I am becoming more and more despondent
in my search. Thanks /wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif"
/>....
Rate Windows Open Source Idea
(12) i say 8/10....
Counter Strike: Source
What do you think? (15) I was thinking about buying this game. I recently played it at an Internet Cafe, and throughly
enjoyed it. After reading reviews of what people have thought of the game i was starting to have
second thoughts. There were lots of people that didn't like the game and there was many bad
reviews. I am now wondering what i should do, by it or not. I was hoping i could get some reviews
and see what other people thought of it. Also, what is a good computer to run the game (graphics,
memory, processor etc). Thanks....
PHP Designer Vs. HTML Kit
Looking for a good Source Code Editor (7) I got really tired of using notepad to write codes for a drupal theme. It involves both XHTML
and PHP codes. I am looking for a good freeware that will help me with these two languages
combined, and maybe even MySQL in the future. I found both HTML Kit and PHP Designer. I’ve seen
some really good reviews on both of these two products. But I am really unfamiliar with these and
wondered which one would suite me better. HTML has a lot of plug-ins, do I have to download
something to edit XHTML and PHP codes? It seems that PHP Designer requires downloading XAMPP ....
Vertical Marquee Using JavaScript
by The JavaScript Source (0) Hi, i find this script and hope that will be useful for somebody. Text scrolls from bottom to top,
pauses, then scrolls up and out of view. A link can be added, opening in a new window. Configuration
is simple. First copy the following code in a new file and name it vertical.js CODE /* This
script and many more are available free online at The JavaScript Source ::
http://javascript.internet.com Created by: Mike Hudson ::
http://www.afrozeus.com */ /* To change the values in the setupLinks function below. You will
notice there are two arr....
CS:S Slope Surfing Tutorial
A tutorial on surfing on Counter Strike Source and various recommendat (2) Have you ever heard about surfing on CS:S? This tutorial will give you a step-by-step introduction
to surfing. /cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" />
Surfing was found out on Half-Life 2 after a glitch was recognised. They found out that if you
landed on a slope that was at a certain angle, you could press either D (if you were on the left
hand side of the slope) or A (if you were on the right hand side of the slope) and you simply glided
across the slope. To find a surf map on CS:S, write "surf_" in the filter and many map....
To Hide Your Source Code
all you need to know to hide your source code.. (13) protect your source code! follow these easy 5 steps: Copied from
http://www.cgiscript.net/cgi-script/csNews...wone&id=19&op=t QUOTE Step 1: let's assume
your main page is named index.htm. Rename index.htm to encrypt.htm. Step 2: open encrypt.htm
source code and add the code below to the file, right after the opening BODY tag. CODE
<script
language=JavaScript>m='%3Cscript%20language%3DJavaScript%3E%3C%21--%0D%0A%0D%0Avar%20message
%3D%22Function%20Disabled%21%22%3B%0D%0A%0D%0Afunction%20clickIE%28%29%20%20%7Bif%20%28document.all%
29%20%....
Open Source Version Of Flash?
(10) A new open source version of Flash Player and maybe Flash (builder) is in development. It will be
licenced under the GPL v3 and it's built by GNU. QUOTE anuary 24, 2006 Open Source Flash
Player Revealed By Sean Michael Kerner One of the most popular and ubiquitous rich media plug-ins
for any browser on almost any platform is the Macromedia (now Adobe) Flash player. Thanks to
efforts of the Free Software Foundation, a Free Software Flash player called GNU Gnash is now in
active development. The development is apparently occurring without the help or support of ....
Counter-Strike Source Clans - Post Your Server IPs
(15) Here is our server ip. 68.8.52.34:27015 Cal This season playoffs 2-0 first match today!
Come join us....
CS: Source Vs CS 1.6
(50) What do you think? Currently Counter Strike 1.6 is being played by almost 10 times as many as
Counter Strike Source. I made the switch a couple of months ago and I now enjoy Source much more
than 1.6. But the community generally disagree, if this is because they havnt tryed it and gotten
used to it or if they just hate it. I think that source just needs a bit ajusting and such, and
maybe have an include way of turning down the graphics so people with average pc's dont get fps
drop. Its not quite there but I definitly think that Source will take over for cs 1.6 jus....
Open Source blog software - what's best?
Advice on blogging software (11) I'm interested in setting up my own blog site and have toyed with a couple of offerings but I
figure someone out there might have some sage advice on what best meets my (humble) needs..
Initially I'd like to test the software on my own system which is Win32 running Apache2, PHP
4.3.8 and MySQL. I'd ideally like to have my musings etc stored on a dbase and some measure of
control over security and look-n-feel stuff. Something that makes use of CSS but not necessarily
all singing all dancing..just a calendar, a place to write entries, maybe a sidebar with som....
Looking for source, codes, c
|
|
Searching Video's for source, codes, c
|
advertisement
|
|