May 16, 2008

C++ Programmers - So Post your C++ programs here

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > C/C++ Programming

free web hosting

C++ Programmers - So Post your C++ programs here

musicmaza
Hi any C++ programmer want to share C++ programs,then post the code here.But it would be good if the programs are not too long.So only short programs.

But post that code in bbcodes-don't forget that.

Anyone who doesn't understand any programs that are posted can take any help here in this thread.

Heres one :

This is a program using class:

CODE
#include<iostream.h>
class sum
{
private:
int a,b,c;
public:
sum()
{
a=5,b=6;
}
sum(int x,int y)
{
a=x,b=y;
}
void get()
{
cin>>a>>b;
}
void calc()
{
c=a+b;
cout<<c;
}
};
void main()
{
sum s1,s2(2,3),s3;
s1.calc();
s2.calc();
s3.get();
s3.calc();
}

Reply

Dark_Prisoner
This is small program that generates a random number and asks you for it
If you guess it than it is right
If you don't it will tell you if it is more or less


It is in french but i think you'll understand the idea (may be i'll make another edition in english !)

CODE
///////////////////////////////////////////////////////////////////////////////
//                   Excellence micro systems® 2007©                         //
//                                                                           //
//   We are glad to present for you our "Plus ou moin v2.0" it is a little   //
//game running under a console for example ms-dos or Konsole ... The "Plus ou//
//moin v1.1.exe" file runs under MS-dos and Windows console.. With the source//
//code you can compile the application and make it work with any OS such as  //
//Windows , Linux , mac OS ... To see what's new on that version pleaze run  //
//the file named "what's new.txt" ....    Now we wish for you a funy time;) //
//                                                                           //
// To contact us please send a mail to Mr Dhia Eddine Chouchane              //
//"assir2@hotmail.fr"                                                        //
//Or take a look at our main site : "http://excellence.247ihost.com"         //
///////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <time.h> //librairie qui permet de tirer un nombre au hazard

int main(int argc, char *argv[])
{
    //Tout d'abord défénir les variables de l'environnement
    long nombreDevined = 0 , nombreMystere = 0 , nombreDeCoups = 0 , choix;
    int MAX = 100 , MIN = 1 , Jeu = 1;

     //L'intro!

    printf("Excellence micro systems presente :\n\nLe jeu de plus ou moin ...");
    printf(" \n\n\n\n\n\n\n");
     //Puis definir la fonction de choix aleatoire
    srand(time(NULL));

     //Apres on commence dans le programme


     //On demande le choix de l'utilisateur
    printf("Que voulez vous faire?\n");
    printf("\n1. Jouer\n");
    printf("2. Quitter l'application\n");
    printf("\n== Entrez le Numero de votre choix et puis ENTRER\n");
    printf("\n\n\n\n\n\nREMARQUE : Pour quitter durant le jeu appuyer sur 0 puis sur ENTRER\n\n");
    scanf("%ld", &choix);
    switch (choix)
    {
          case 1 :;
          break;
          case 2 :
               printf("Tu vas quitter le jeu !!\n\n\n");
               Jeu = 0;
          break;
          default : printf("Ton choix ne figure pas dans la liste\n");
          break;
          }

    // On entre dans une boucle pour pouvoir rejouer afin d'accomplir le jeu
    while (Jeu)
    {
        //Le programme charge un nombre au hasard
        nombreMystere = (rand() % (MAX - MIN + 1)) + MIN;

           /* On redefinie nombreDevined en 0 pour que ça ne pe jamais etre égal
           avec nombreMystere*/
           nombreDevined = 0;
           while (nombreDevined != nombreMystere)
           {
                 //On demande le nombre
                 printf("Quel est le nombre ?");
                 scanf("%ld", &nombreDevined);
                 nombreDeCoups++;

                 //Puis on fait l'analyse
                 if (nombreDevined == nombreMystere)
                 {
                       printf("Bravo, vous avez trouve le nombre mystere en %ld essais!!!\n\n" , nombreDeCoups);

                       //On demande de l'utilisateur si il veux rejouer
                       printf("Voulez vous jouer une deuxieme fois?\n");
                       printf("si oui tapez 1 puis ENTRER\n");
                       printf("si non tapez 2 puis ENTRER\n");
                       scanf("%ld", &choix);

                       switch (choix)
                       {
                            case 1 : Jeu = 1;
                            break;
                            case 2 : Jeu = 0;
                            break;
                            default : printf("Ton choix ne figure pas dans la liste\n");
                                      printf("Tu vas quitter le jeu\n");
                                      break;
                            }

                       }
                 //N'oublions pas que nous sommes toujours en analyse
                 if (nombreDevined == 0)
                 {
                       printf("\n\nTus va quitter le jeu\n\n\n");
                       Jeu = 0;
                       nombreDevined = nombreMystere;
                       }


                  else if (nombreDevined > nombreMystere)
                  {
                      printf("C'est moins !\n\n");

                      }

                  else if (nombreDevined < nombreMystere)
                  {
                      printf("C'est plus !\n\n");

                      }

                  else printf("Ce que tu a entre est faux ou tu a choisis de quitter l'application\n\n");
                  }
         }
  /*demander de l'utilisateur de taper une touche pour continuer afin qu'il
  peut voir ce qui c'est écrit*/
  system("PAUSE");
  return 0;
}
////////////////////////////////////////////////////////////////////////////////
//         All rights reserved to Excellence micro systems® 18/08/2007©       //
//              and to its owner Mr. Dhia Eddine Chouchane                    //
////////////////////////////////////////////////////////////////////////////////


Now how about some optimizations ?

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. "dhia eddine chouchane" - 898.10 hr back.
  2. c programmers - 1267.34 hr back.
Similar Topics

Keywords : c, programmers, post, c, programs

  1. Mouse Input In C Programs
    using checkbox etc (5)
  2. Simple C++ Programs.
    simple programs for beginners. (17)
    if you want to start c++ programing read and train this simple programs. CODE 1."using
    ? command." #include <iostream.h> #include <conio.h> int main(){
    clrscr(); float a,b,c,d; cin >>a>>b>>c>>d;
    a=(a>c+d)?(a*c) : (b*d); cout <<"a="<<a;
    getch(); return 0; } [/indent] [indent] 2."using of while loop
    command." #include <iostream.h> #include <conio.h> int main(){
    clrscr(); floa....
  3. Programs
    for games (4)
    first off i would like to announce this is my first time on here, i would like to know what kind of
    programs i need to edit my Pc games. i have been learning how to edit with just texts but i would
    like to know what i need for the text scripts i can't read? any information can help
    --thanks....
  4. Buffer Overflow In Action Tutorial
    Learn how to buffer overflow programs to change the program flow... (0)
    This tutorial will show you how to buffer overflow programs in order to change the flow of the
    application , even if this means executing your own code. A very well explained tutorial of buffer
    overflows ( not theory but practise ) + a 20 min video tutorial/demonstration + all the files needed
    for the tutorial.. Buffer Overflow In Action Tutorial LINK ....
  5. C/c++ Programming Experince
    How long does it take before programming useful programs? (3)
    I've been teaching my self C++, slowly but surely. Everything I try to program is just mediocre,
    and much simplier to use something already made. How long does it take before I can start
    programming useful decent programs?....
  6. Can't Compile Assembly Programs.
    (2)
    Hi, I'm trying to learn assembly but I can't compile any "hello world" programs... And I
    don'n know what I'm doing wrong... I downloaded NASM ,NASMW and TASM32. The program is like
    this: EXAMP1.ASM: ;title Hello World Program ; This program displays "Hello, World!"
    dosseg .model small .stack 100h .data hello_message db 'Hello,
    World!',0dh,0ah,'$' .code main proc mov ax,@data mov ds,ax
    mov ah,9 mov dx,offset hello_message int 21h mov ax,4C00h
    int 2....
  7. Programmer's Technical Reference For Msdos And The Ibm Pc
    (0)
    This archive contains a demo version of DOSREF. It contains 95% of the basic information you
    actually need to program a PC under DOS. You're welcome to use this demo without obligation or
    payment, ....
  8. The Pc Games Programmers Encyclopedia 1.0
    (5)
    The PC-GPE ( PC GAMES PROGRAMMERS ENCYCLOPEDIA)as it currently stands is a collection of text files,
    each covering a different aspect of programming games for the PC.Some files were obtained from the
    net, others were grabbed off Usenet, quite a few were written for the PC-GPE. Every effort has been
    made to contact the original authors of all public domain articles obtained via ftp. In some cases
    the original authors were not able to be contacted. Seeing as these files were already available to
    the public the liberty was taken to include them anyway. The files were not mo....
  9. C++
    C++... a Programmers Program... Or is it? (15)
    Ok, I was tempted to put this into the PC Coding section, however I figured it was more of a
    question about the program than the coding... I am a pretty avid programmer when it comes to Visual
    Basic... Though now, I think its time to move into a little more advanced coding, and teach myself
    something new. From what I hear around with friends and people I know, C++ is a good program for
    programming, and really gets you to learn the ropes... Is this what your guys' opinion of the
    program would roughly be? Also, does anyone here know where I can either pick up a demo o....
  10. Simple C++ Programs
    programming C++ (13)
    what simple programs would a beginner should code in order to get some understanding the c++ along
    with leaning as well....

    1. Looking for c, programmers, post, c, programs

Searching Video's for c, programmers, post, c, programs
advertisement



C++ Programmers - So Post your C++ programs here



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE