Go Back   Gaming Gutter > Non-Gaming > Programming > Source Code


Source Code - Have a source code/project files you want to post? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post Heather wants to kill a...
Today 06:49 PM
Last post by .BloodyNightmare
Today 09:58 PM
24 Replies, 84 Views
Go to first new post Benita just got her...
Today 04:43 PM
Last post by Axed
Today 09:57 PM
18 Replies, 107 Views
Go to first new post Trading very old NP...
Today 05:15 PM
by devl014
Last post by devl014
Today 09:53 PM
6 Replies, 24 Views
Go to first new post Buy it NOW! Special...
11-19-2008 10:30 PM
Last post by l_royalty_l
Today 09:53 PM
20 Replies, 229 Views
Go to first new post Consumption
Today 09:23 PM
by Axed
Last post by Axed
Today 09:50 PM
2 Replies, 3 Views
Reply
 
LinkBack Thread Tools Display Modes

 Some simple C++ programs
Old 12-16-2006, 06:17 AM   #1 (permalink)
Underground

Male gommle is offline
 
gommle's Avatar
 
Join Date: Sep 2006
Location: The o great land of Nooooooreeeway
Age: 20
Posts: 658
GPoints: 38
iTrader: 0 / 0%
gommle Is Recognizable
Rep Power: 7
Some simple C++ programs

Nothing complicated, I just began a bit with C++.

http://vestberg.net/~gommlem/dir/files/cppBeep.rar
http://vestberg.net/~gommlem/dir/files/cppCtoF.rar
http://vestberg.net/~gommlem/dir/files/cppTimer.rar

CppBeep
PHP Code:
//

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <windows.h>
using namespace std;

int main(int nNumberofArgscharpszArgs[])
{
    
cout << endl << "This program will use your internal PC speaker to output ";
    
cout << endl << "tones. The program will simply start beeping while       ";
    
cout << endl << "increasing the pitch. You can choose the length, pitch   ";
    
cout << endl << "amount of beeps, and frequency increment for each beep.  ";
    
cout << endl << "Press Ctrl+C to exit the program. The values in paranthesis";
    
cout << endl << "are default values.";
    
cout << endl << endl << "-----------------Made by Gommle------------------------- ";


    
// define tone lengths
    
int lWhole;
    
int lHalf;
    
int lQuarter;
    
int lEight;
    
int lSixteenth;
    
    
lWhole 1600;
    
lHalf lWhole/2;
    
lQuarter lHalf/2;
    
lEight lQuarter/2;
    
lSixteenth lEight/2;
    
    
// define tone frequencys
    
int tLowG 196;
    
int tA 220;
    
int tHighA 233;
    
int tB 247;
    
int tC 262;
    
int tHighC 277;
    
int tD 294;
    
int tHighD 311;
    
int tE 330;
    
int tF 349;
    
int tHighF 370;
    
int tG 392;
    
int tHighG 415;
    
    
cout << endl << "(0 or 1) Do you want to play some songs from the jukebox?";
    
int jukeplay;
    
cin >> jukeplay;
    
int SongToneLength 210;
    while(
jukeplay==1)
    {
        
int song;
        
cout << endl << "Available options:";
        
cout << endl << "1. Play Mortal Combat theme";
        
cout << endl << "2. Play Super Mario Bros theme";
        
cout << endl << "3. Play Star Wars theme";
        
cout << endl << "4. Exit Jukebox";
        
cout << endl << endl << "(1-4) Which option do you choose?";
        
cout << endl << endl << "Song:";
        
cin >> song;
        switch(
song)
        {
            case 
1:
                
// play the mortal combat theme
                
Beep(tASongToneLength);Sleep(10);
                
Beep(tASongToneLength);Sleep(10);
                
Beep(tCSongToneLength);Sleep(10);
                
Beep(tASongToneLength);Sleep(10);
                
Beep(tDSongToneLength);Sleep(10);
                
Beep(tASongToneLength);Sleep(10);
                
Beep(tESongToneLength);Sleep(10);
                
Beep(tDSongToneLength);Sleep(10);
                
Beep(tCSongToneLength);Sleep(10);
                
Beep(tCSongToneLength);Sleep(10);
                
Beep(tESongToneLength);Sleep(10);
                
Beep(tCSongToneLength);Sleep(10);
                
Beep(tFSongToneLength);Sleep(10);
                
Beep(tCSongToneLength);Sleep(10);
                
Beep(tGSongToneLength);Sleep(10);
                
Beep(tFSongToneLength);Sleep(10);

            break;
            
               case 
2:
                
// play themario theme
                
Beep(tESongToneLength);
                
Sleep(10);
                
Beep(tESongToneLength);
                
Sleep(10);
                
Beep(tESongToneLength);
                
Sleep(10);
                
Beep(tCSongToneLength);
                
Sleep(10);
                
Beep(tESongToneLength);
                
Sleep(10);
                
Beep(tHighGSongToneLength*2);
                
Sleep(10);
                
Sleep(SongToneLength);
                
Beep(tGSongToneLength);
                
Sleep(10);
                
Sleep(SongToneLength);
                
Sleep(SongToneLength);
                
Sleep(SongToneLength);
            break;
            
            case 
3:
                
// play darth vader thingy
                
Beep(tASongToneLength*2); Sleep(10);
                
Beep(tASongToneLength*2); Sleep(10);
                
Beep(tASongToneLength*2); Sleep(10);
                
Beep(tFSongToneLength); Sleep(10);
                
Beep(tCSongToneLength); Sleep(10);
                
Beep(tASongToneLength*2); Sleep(10);
                
Beep(tFSongToneLength); Sleep(10);
                
Beep(tCSongToneLength); Sleep(10);
                
Beep(tASongToneLength*3); Sleep(10);
                
Beep(tESongToneLength); Sleep(10);
                
Beep(tHighASongToneLength*2); Sleep(10);
                
Beep(tHighASongToneLength*2); Sleep(10);
                
Beep(tHighASongToneLength*2); Sleep(10);
                
Beep(tHighFSongToneLength); Sleep(10);
                
Beep(tHighCSongToneLength); Sleep(10);
                
Beep(tHighASongToneLength*2); Sleep(10);
                
Beep(tHighFSongToneLength); Sleep(10);
                
Beep(tHighCSongToneLength); Sleep(10);
                
Beep(tHighASongToneLength*3); Sleep(10);
                
Beep(tESongToneLength); Sleep(10);
            break;
            
            case 
4:
                
jukeplay 0;
            break;
            
        }
    }
    
//start the main loop

    
while(1==1){
        
// define the frequency increment
        
int nFrequencyInc;
        
cout << endl << endl << "(30)  Frequency increment for each loop: ";
        
cin >> nFrequencyInc;

        
// define the frequency increment
        
int nFrequencyStart;
        
cout << endl << "(180) Frequency start position: ";
        
cin >> nFrequencyStart;

        
// define the amount of beeps
        
int nTones;
        
cout << endl << "(10)  Amount of beeps: ";
        
cin >> nTones;

        
// define the tone length
        
int nLength;
        
cout << endl << "(200) Tone length: ";
        
cin >> nLength;
        
        
// define the delay after tones
        
int nDelay;
        
cout << endl << "(40) Delay between tones: ";
        
cin >> nDelay;

        
// declare variables for the loop
        
int nCounter;
        
nCounter 0;
        
int nFrequency;
        
nFrequency nFrequencyStart;

        
// echo the amount of tones specified
        
while(nCounter nTones)
        {
            
// beep
            
Beep(nFrequencynLength);
            
// increment the frequency by the user input
            
nFrequency nFrequencyInc nFrequency;
            
nCounter++;
            
Sleep(nDelay);
        }
    }

CppTimer
PHP Code:
//
// This program beeps after x minutes. Ideal for pizza making.
// Todo:
//      Presets for different types of Pizza, cold oven and warm oven
//
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <windows.h>
using namespace std;


int main(int nNumberofArgscharpszArgs[])
{
     
// get minutes
     
int nMinutes;
     
cout << "This program will count down from a time you specify and make a";
     
cout << "beep sound when it's done";
     
cout << endl << "Minutes to wait: ";
    
cin >> nMinutes
    
cout << endl << nMinutes << " minutes left..." <<endl;
    
    
// echo remaining minutes each minute
    
while(nMinutes 0)
    {
        --
nMinutes;
        
Sleep(60000);
        
cout << nMinutes << " minutes left..." << endl;

    }
    
// wait for the user to press a key
    
Beep(600,200);
    
Beep(500,200);
    
Beep(400,200);
    
MessageBox (NULL"Timer finished!" "Timer"0);
    
cout << nMinutes << "Done!" << endl;
    
system("PAUSE");

CppCelsiustoFahrenheit
PHP Code:
//
// Program to convert temperature from Celsius degree
// units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212-32)/100 + 32
//

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgscharpszArgs[])
{
    
// enter the temperature in Celsius
    
int celsius;
    
cout << "Enter the temperature in Celsius:";
    
cin >> celsius;
    
    
// calculate conversion factor for Celsius
    // to Fahrenheit
    
int factor;
    
factor 212 32;
    
    
// use conversion factor to convert Celsius
    // to Fahrenheit
    
int fahrenheit;
    
fahrenheit factor celsius/100 32;
    
cout << "Fahrenheit value is: ";
    
cout << fahrenheit << endl;   
    
    
// wait until user is ready before terminating program
    // to allow the user to see the program results
    
system("PAUSE");
    return 
0;

The first one is really fun at school. Try setting the tone to 2400-2600, length to 1000, and delay to 30-200 secs.

All of them will only work on Windows by the way.
__________________

  Reply With Quote

 Re: Some simple C++ programs
Old 02-03-2007, 06:51 AM   #2 (permalink)

Male virusdetected is offline
 
virusdetected's Avatar
 
Join Date: Dec 2006
Age: 17
Posts: 6,460
GPoints: 1,014
iTrader: 0 / 0%
virusdetected Is Popular
Rep Power: 15
Re: Some simple C++ programs

The first one is kinda cool gj xD
I'm going to try it in school. hehe
__________________
Quote:
Originally Posted by Fewmitz View Post
Do more drugs to avoid the come down from all of the drugs?

Virus, your logic is flawless.
Current Anime Watchlist:

Elfen Lied - FINISHED T_T <3
D.Gray-Man - Up To Episode 40
Tenchi Muyo - Up To Episode 13
Night Wizard - Up To Episode 5

  Reply With Quote

 
Old 07-18-2007, 08:19 PM   #3 (permalink)
Underground

Ricardandroy is offline
 
Ricardandroy's Avatar
 
Join Date: Jun 2007
Posts: 98
GPoints: 1
iTrader: 0 / 0%
Ricardandroy Is gaining popularity
Rep Power: 5
really simple, when i am in highschool , i did the same thing
  Reply With Quote

 
Old 07-28-2007, 08:06 PM   #4 (permalink)
Resident Psychopath.

Male Fewmitz is offline


 
Fewmitz's Avatar
 
Join Date: Nov 2006
Location: fewmitz@live.com
Posts: 5,378
GPoints: 2,485
iTrader: 1 / 100%
Fewmitz Is a Party CaptainFewmitz Is a Party CaptainFewmitz Is a Party Captain
Rep Power: 17
Quote:
Originally Posted by Ricardandroy View Post
really simple, when i am in highschool , i did the same thing
Did you also pass English?
  Reply With Quote

 
Old 08-12-2007, 09:03 AM   #5 (permalink)
Underground

Male gommle is offline
 
gommle's Avatar
 
Join Date: Sep 2006
Location: The o great land of Nooooooreeeway
Age: 20
Posts: 658
GPoints: 38
iTrader: 0 / 0%
gommle Is Recognizable
Rep Power: 7
I do this when I am 14 ;)

(Yes, pun intended.)
__________________

  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 09:59 PM.


vBulletin skin developed by: eXtremepixels
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.12189507 seconds (100.00% PHP - 0% MySQL) with 19 queries