• Log in or sign up for an account here: https://www.sythe.org/login

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

Xiang_Chu

Forum Addict
Joined
Mar 17, 2011
Sythe Gold
0
Messages
384
Location
Skill Training Section.

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";
}











​
 
Runescape Gamblingrunescape gambling
Back
Top