Вы находитесь на странице: 1из 3

Programs in C++:

#include<iostream.h> //Program to calculate Area of Circle


#include<constream.h>
void main()
{ clrscr(); int r; float A,Pi=3.14;
cout<<"Enter the value of Radius = ";
cin>>r;
A=Pi*r*r;
cout<<A;
getche(); }

#include<iostream.h> //Program to display Bio data


#include<constream.h>
void main()
{ clrscr();
cout<<"Name: Muhammad Saeed"<<endl<<"Surname: Rattar"<<endl<<"Nationality:
Pakistani"<<endl<<"Email: m_saeed1991@yahoo.com";
getche(); }

#include<constream.h> //Even numbers from 1 to 100 by do while loop


void main()
{ clrscr();
int a=1;
do {cout<<a++*2;}
while (a<=50);
getche(); }

#include<constream.h> //Numbers from 1 to 100 by do while loop


void main()
{ clrscr();
int a=1;
do {cout<<a++;}
while (a<=100);
getche(); }

#include<iostream.h> //Program to convert temperature from celsius to fahrenhiet


#include<constream.h>
void main()
{ clrscr(); float F,C;
cout<<"Enter the value of temperature in Celsius = ";
cin>>C;
F=1.8*C+32;
cout<<F;

1
getche(); }

#include<iostream.h> // display "HELLO" on screen


#include<constream.h>
void main()
{ clrscr(); cout<<"hello";
getche(); }

#include<constream.h> // Display even number from 1 to 100 by using for loop


void main()
{ clrscr();
int a;
for (a=1;a<=50;a++)
cout<<a*2;
getche(); }

#include<iostream.h> //Program to calculate voltage across resistor by Ohm's Law


#include<constream.h>
void main()
{ clrscr(); int V,I,R;
cout<<"Enter the value of Current and Resistance = ";
cin>>I>>R;
V=I*R;
cout<<V;
getche(); }

#include<iostream.h> //Program to calculate Power dissipation across resistor when


value of resistance and current are given
#include<constream.h>
void main()
{ clrscr(); float P,I,R;
cout<<"Enter the value of Current and Resistance = ";
cin>>I>>R;
P=I*I*R;
cout<<P;
getche(); }

2
#include<constream.h> // Display Even or Odd numbers by using SWITCH
#include<iostream.h>
void main()
{ clrscr();
char num,e,o; int a;
cout<<"Press e for EVEN NUMBERS"<<endl;
cout<< "Press o for ODD NUMBERS"<<endl;
cin>>num;
switch(num)
{case 'e':
for(a=1;a<=50;a++)
cout<<a*2;
break;
case 'o':
for(a=1;a<=50;a++)
cout<<a*2-1;
break;
default:
cout<<"Invalid input"; }
getche(); }

#include<constream.h> //Even numbers from 1 to 100 by using while loop


void main()
{ clrscr();
int a=1;
while (a<=50)
{cout<<a++*2;}
getche(); }

Вам также может понравиться