Leap Year // C++


#include<iostream.h>
#include<conio.h>

void main(void)
{
	clrscr();

	int yr;

	cout<<"Enter Year: ";
	cin>>yr;

	if(yr%4==0)
	{
		cout<<"\n\nYes ! It Is A Leap Year";
	}
	else
	{
		cout<<"\n\nNo ! It Is Not A Leap Year";
	}

	getche();
}

Celsius to Fehrenheit


#include<conio.h>
#include<iostream.h>

void main(void)
{
	clrscr();

	float c;
	float f;

	cout<<"Enter Value in Celsius: ";
	cin>>c;

	f = ((c/5)*9)+32;

	cout<<"The Value In Fahrenheit: "<<f;

	getche();
}

Relational Operators


#include<iostream.h>
#include<conio.h>

void main(void)

{
	clrscr();

	int n1;
	int n2;

	cout<<"Enter Number 1: ";
	cin>>n1;

	cout<<"Enter Number 2: ";
	cin>>n2;

	n1==n2;
	n1!=n2;
	n1<n2;
	n1>n2;

	if(n1==n2)
	{
		cout<<endl<<endl<<n1<<" is equal to "<<n2;
	}

	if(n1!=n2)
	{
		cout<<endl<<endl<<n1<<" is not equal to "<<n2;
	}

	if(n1<n2)
	{
		cout<<endl<<endl<<n1<<" is less than "<<n2;
	}

	if(n1>n2)
	{
		cout<<endl<<endl<<n1<<" is greater than "<<n2;
	}

	getche();

}

Calcutating Diameter, Cricumference and Area of a Circle


#include<iostream.h>
#include<conio.h>

void main(void)
{
	clrscr();

	double ar,dia,rad,cir;
	double pi=3.14156;

	cout<<"Enter Radius of Circle: ";
	cin>>rad;

	dia=2*rad;
	cir=2*pi*rad;
	ar=pi*(rad*rad);

	cout<<"\n\nDiameteer is: "<<dia;
	cout<<"\n\nCircumference is: "<<cir;
	cout<<"\n\nArea is: "<<ar;

	getche();
}

Factorial using for loop


#include<iostream.h>
#include<conio.h>

void main (void)
{
	clrscr();

	int num;
	cout<<"Enter Number :";
	cin>>num;

	int result = 1;
	for(int i = num; i > 1; i--)
	{
		result = i * result;
	}

	cout<< result;

	getche();
}

Printing Tables in C++


#include<iostream.h>
#include<conio.h>

void main (void)
{
clrscr();

int num;
cout<<"Enter Number :";
cin>>num;

for(int i = 1; i <= 10; i++)
{
cout<< num << "*" << i << "=" << num*i << endl;
}

getche();
}

Hello world!

#include <iostream.h>

#include<conio.h>

int main()

{

clrscr();

cout<<"Hello World !";

return 0;

getche();

}