[Basic C++]~Xiang's C++ Programs~[Updated Regularly]

Discussion in 'Programming General' started by Xiang_Chu, May 17, 2011.

[Basic C++]~Xiang's C++ Programs~[Updated Regularly]
  1. Unread #1 - May 17, 2011 at 8:12 AM
  2. Xiang_Chu
    Joined:
    Mar 17, 2011
    Posts:
    384
    Referrals:
    1
    Sythe Gold:
    0

    Xiang_Chu Forum Addict
    Banned

    [Basic C++]~Xiang's C++ Programs~[Updated Regularly]


    Welcome fellow Coders :) I am currently learning C++ and as i learn, i would like to post all the programs here, so that other people who are also learning C++ might get help in some way or the other. The programs i will be posting are very general and few of the most basic programs, they may have been posted here before, but my point of doing this is to basically make a compilation or an archive of such programs so that people can get help for their school work, or just for the fun of learning :D


    NOTE: Please no flaming guys! this is made entirely for extreme beginners and it is just to help out, i am NOT posting this to get my Post count up>.>

    ~I will Update this thread Regularly, so if you are finding this useful, don't forget to check this thread Everyday! :D

    Program to calculate the sum of 2 numbers.
    Code:
    #include<iostream.h>
    #include<conio.h>
    void main ()
    { clrscr ();
    int a,b,S;  //S is the variable ive used for sum
    cout<<"Enter Number 1:\n;
    cin>>a;
    cout<<"Enter Number 2:\n;
    cin>>b;
    S=a+b;
    cout<<"Sum ="<<S;
    }

    Program to calculate the area of a rectangle.
    Code:
    #include<iostream.h>
    #include<conio.h>
    void main ()
    { clrscr ();
    float l,b,A; //A is for Area
    cout<<"Enter Length\n";
    cin>>>l;
    cout<<"Enter Breadth\n";
    cin>>b;
    A=l*b;
    cout<<"Area =";
    cout<<A;
    }
    
    Program to calculate the volume of a cuboid.

    Code:
    #include<iostream.h>
    #include<conio.h>
    void main ()
    { clrscr ();
    float l,b,h,V; //V stands for Volume
    cout<<"Enter Length\n";
    cin>>l;
    cout<<"Enter Breadth\n";
    cin>>b;
    cout<<"Enter Height\n";
    cin>>h;
    V=l*b*h;
    cout<<"Volume =";
    cout<<V;
    }
    
    Program to find Simple Interest.

    Code:
    #include<iostream.h>
    #include<conio.h>
    void main ()
    { clrscr ();
    float P,R,T,Si;
    cout<<"Enter Principal\n";
    cin>>P;
    cout<<"Enter Rate\n";
    cin>>R;
    cout<<"Enter Time\n";
    cin>>T;
    Si=(P*R*T)/100;
    cout<<"Simple Interest =";
    cout<<Si;
    }
    
    Program to calculate Area of a Circle.

    Code:
    #include<iostream.h>
    #include<conio.h>
    void main()
    { clrscr();
    float Pi,R,A;
    const Pi = 3.14;
    cout<<"Enter Radius:\n";
    cin>>R;
    A=Pi*R*R;
    cout<<"Area="<<A<<"cm^2";
    }
    
    Program to calculate area of a triangle.

    Code:
    #include<iostream.h>
    #include<conio.h>
    void main()
    {clrscr();
    float b,h,A; //A is for Area
    cout<<"Enter Base:\n";
    cin>>b;
    cout<<"Enter Height\n";
    cin>>h;
    A=(b*h)/2;
    cout<<"Area ="<<A<<"cm^2";
    }
    
    Program to convert Fahrenheit to Celcius.

    Code:
    #include<iostream.h>
    #include<conio.h>
    void main()
    { clrscr ();
    float F,C;
    cout<<"Enter Temperature in Fahrenheit:\n";
    cin>>F;
    C=(F-32)*5/9;
    cout<<"Temperature in Celcius="<<C<<"Degrees Celcius";
    }
    










     
  3. Unread #2 - May 30, 2011 at 4:12 AM
  4. Drunk Dragon
    Joined:
    Mar 30, 2011
    Posts:
    633
    Referrals:
    0
    Sythe Gold:
    0

    Drunk Dragon Apprentice
    Banned

    [Basic C++]~Xiang's C++ Programs~[Updated Regularly]

    Thanks for SI, helped me with a project i'm currently trying to attempt! ;)

    ~ DD
     
  5. Unread #3 - May 31, 2011 at 8:10 PM
  6. QuasiNoob
    Joined:
    May 27, 2011
    Posts:
    179
    Referrals:
    12
    Sythe Gold:
    0

    QuasiNoob Active Member

    [Basic C++]~Xiang's C++ Programs~[Updated Regularly]

    Nice programs. I'm self-teaching C++ too. What compiler do you use?
     
  7. Unread #4 - May 31, 2011 at 10:10 PM
  8. AlexServices
    Joined:
    Mar 1, 2010
    Posts:
    219
    Referrals:
    0
    Sythe Gold:
    0

    AlexServices Active Member
    Banned

    [Basic C++]~Xiang's C++ Programs~[Updated Regularly]

    thanks im trying to learn this shit... seems hard but im getting it slowly slowly
     
< Java RS Bot help | [WIP]Java Tower Defence >

Users viewing this thread
1 guest


 
 
Adblock breaks this site