My first C++ program:)

c, c++, php, html, sql ..etc discussion. also includes codes and source codes.

My first C++ program:)

Postby PinPoint » Mon Nov 22, 2010 12:44 pm

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
Attachments
average age cpp test.rar
(104.41 KiB) Downloaded 171 times
Last edited by PinPoint on Mon Nov 22, 2010 8:57 pm, edited 1 time in total.
User avatar
PinPoint
Special
Special
 
Posts: 128
Joined: Wed Dec 03, 2008 6:41 pm

Re: My first C++ program:)

Postby Sethioz » Mon Nov 22, 2010 6:28 pm

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.
User avatar
Sethioz
Admin
Admin
 
Posts: 4757
Joined: Fri Jul 27, 2007 5:11 pm
Location: unknown


Return to Programming / Coding / Debugging

Who is online

Users browsing this forum: No registered users and 3 guests