Sep 21, 2011

These simple programs written in programming language C + +

1-Program conducted by addition and multiplication and subtraction of two numbers:

#include <iostream.h>
#include <conio.h>
void main ()
{
int x, y;
cout << "x= ";
cin >> x;
cout << "y= ";
cin >> y;
cout << "x+y= " << x+y << endl;
cout << "x-y= " << x-y << endl;
cout << "x*y= " << x*y << endl;
if (y != 0)
cout << "x/y= " << (float)x/y << endl;
getch ();
}



2-Program conducted by addition and multiplication and subtraction of two numbers to the number of times specified by the user





#include <iostream.h>
#include <conio.h>
void main ()
{
float L, M;
char ch;
do
{
cout << "\nEnter L: ";
cin >> L;
cout << "Enter M: ";
cin >> M;
cout << "\nL+M= " << L+M;
cout << "\nL-M= " << L-M;
cout << "\nL*M= " << L*M;
if (M != 0)
cout << "\nL/M= " << L/M;
cout << " \n Do Again (y/n): ";
cin >> ch;
}
while (ch != 'n');
getch ();
}




3-A program that shows the letter E on the screen through a written letter x




#include <iostream.h>
#include <conio.h>
void main ( )
{
cout << "xxxxxxxx" << endl;
cout << "x" << endl;
cout << "x" << endl;
cout << "xxxxxxxx" << endl;
cout << "x" << endl;
cout << "x" << endl;
cout << "xxxxxxxx" << endl;
getch ();
}




4-This program will show the  squares  of numbers from 1 to 14:



#include <iostream.h>
#include <conio.h>
void main ( )
{
for (int i = 0; i < 15; i++)
cout << i * i << " ";
getch ();
}



5-This program calculates the area of ​​a circle in terms of the radius of the circle




#include <iostream.h>
#include <conio.h>
void main ( )
{
float R, Area;
float p1 = 3.14159 ;
cout << " Enter radius of circle: " ;
cin >> R;
Area = p1 * R * R;
cout << " Area is: " << Area << endl;



getch ();
}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Premium Wordpress Themes