For Downloading DEV-C++ Click Here
C++ Program For Addition, Subtraction, Multiplication, Division, Modulus, And Average
Your First Step is To Analysis The Following Code and Write And Modify it By Own. Below are some basic programs in C++ for understanding the syntax of C++
C++ Program For Addition
#include <iostream> //header file for input output
using namespace std; // for initilize input output statement
int main() //starting a program
{
long a, b, c; // long is a data type you can use float,double,and int
cout << "enter the two nuber :" << endl;
cin >> a >> b; //enter value a nad then b
c = a + b; //store sum in c
cout << "sum is = " << c << endl; //print sum
return 0;
}
C++ Program to Subtraction Two Numbers
#include <iostream> //header file for input output
using namespace std; // for initilize input output statement
int main() //starting a program
{
long a, b, c; // long is a data type you can use float, double, and int
cout << "enter the two numbers :" << endl;
cin >> a >> b; //enter value a nad then b
c = a - b; //store sum in c
cout << "subtraction is = " << c << endl; //print sum
return 0;
}
C++ Program to Multiplication Two Numbers
#include <iostream> //header file for input-output
using namespace std; // for initialise input-output statement
int main() //starting a program
{
long a, b, c; // long is a data type you can use float,double,and int
cout << "enter the two nuber :" << endl;
cin >> a >> b; //enter value a nad then b
c = a * b; //store sum in c
cout << "multiple is = " << c << endl; //print sum
return 0;
}
C++ Program to Division Two Numbers
#include <iostream> //header file for input output
using namespace std; // for initilize input output statement
int main() //starting a program
{
long a, b, c; // long is a data type you can use float,double,and int
cout << "enter the two nuber :" << endl;
cin >> a >> b; //enter value a nad then b
c = a / b; //store sum in c
cout << "devision is = " << c << endl; //print sum
return 0;
}
C++ Program to Modulus Two Numbers
#include <iostream> //header file for input output
using namespace std; // for initilize input output statement
int main() //starting a program
{
long a, b, c; // long is a data type you can use float,double,and int
cout << "enter the two nuber :" << endl;
cin >> a >> b; //enter value a nad then b
c = a % b; //store sum in c
cout << "modulus is = " << c << endl; //print sum
return 0;
}
C++ Program to Average Two Numbers
#include <iostream> //header file for input output
using namespace std; // for initilize input output statement
int main() //starting a program
{
long a, b, c; // long is a data type you can use float,double,and int
cout << "enter the two nuber :" << endl;
cin >> a >> b; //enter value a nad then b
c = (a + b) / 2; //store sum in c
cout << "avg is = " << c << endl; //print sum
return 0;
}
Thanks for providing these programs, is turbo c++ ide good to code in c++ language or to just practice programs for beginners.
ReplyDelete