Page 1 of 1

My first C++ program:)

Posted: Mon Nov 22, 2010 12:44 pm
by PinPoint
After a couple of hours of learning C++ i wrote this from memory and it worked so thought id post it.
its just a simple exe for finding the average age of 5 people.

here's the source

Code: Select all

//1st program written PinPoint from memory for the purpose of finding 
//the average age of 5 people

#include <iostream>
#include <cstdio>

int main()
{
    int Age1, Age2, Age3, Age4, Age5;
    int AverageAge;
    std::cout << " Age of person 1 = ";                       //promt user to input age
    std::cin >> Age1;
    std::cout << " Age of person 2 = ";
    std::cin >> Age2;
    std::cout << " Age of person 3 = ";
    std::cin >> Age3;
    std::cout << " Age of person 4 = ";
    std::cin >> Age4;
    std::cout << " Age of person 5 = ";
    std::cin >> Age5;
    AverageAge = (Age1+Age2+Age3+Age4+Age5)/5;
    std::cout << std::endl
         << "AverageAge is " << AverageAge;
         getchar();
         << std::endl;
         std::cout << std::endl
         << "Press Enter to exit...";    
         getchar();
        
        return 0;
}
ive uploaded the exe and the code

Re: My first C++ program:)

Posted: Mon Nov 22, 2010 6:28 pm
by Sethioz
here's few suggestions to help you get started.

try writing a program that manages wordlists. for example replaces spaces with new-line, to make a wordlist
another option would be to list words either alphabethically (ascending and descending options) or by lenght.
also something that would remove dublicated words from list.
i dont need any of this, cuz raptor3 can do that (i also have other tools), but this would help you understand real life situations, which can come in handy.

also what helps is to write some flooders or programs that Luigi makes. no need to get GUI, its useless and senseless. cmd based is best.
I rewrote Luigi's flashchatz to work with "pro chatrooms" and it worked nicely. some bugs, but it did what it was supposue to do > flooded the chatroom with fake users.