Tuesday, December 20, 2011

Reverse Floyds Triangle

7 8 9 10
4 5 6
2 3
1


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
i=7;
for(j=3;j>=0;j--)
{
for(k=0;k<=j;k++)
{
printf("%d ",(i+k));
}
i=i-j;
printf("\n");
}
getch();
}

Check Leap Year in C++


//Write a program to check whether the year is leap or not
#include <iostream.h>
#include <conio.h>
void main ()
{
int y;
clrscr ();
cout <<"Enter Year: ";
cin >>y;
if (y%4==0)
{
cout <<"Year is Leap";
}
else
{
cout <<"Year is not Leap";
}
getch ();
}

Calculate bill with discount in C++


/*Enter Quantity and cost, Calculate total Bill According to the Following Condition:
if bill is greater than 200 then 2% discount
otherwise give 3% discount */

#include <iostream.h>
#include <conio.h>
void main ()
{
int bill, disc, total, qty, cost;
cout <<" Enter Quantity: ";
cin >>qty;
cout <<" Enter Cost: ";
cin >>cost;
bill=qty*cost;
if (bill>200)
{
disc=bill*2/100;
}
else
{
disc=bill*3/100;
}
total=bill-disc;
cout <<"Total Bill After Discount: "<<total;
getch ();
}

Check Odd or Even Number in C++


//Write a program to find whether number is odd or even.
#include <iostream.h>
#include <conio.h>
void main ()
{
int a;
clrscr ();
cout <<"Enter Any Number: ";
cin >>a;
if (a%2==0)
{
cout <<"Number is Even";
}
else
{
cout <<"\n Number is Odd;
}
getch ();
}

Find Greater between two numbers in C++


//Write a program to find greater between two numbers
#include <iostream.h>
#include <conio.h>
void main ()
{
int a,b;
clrscr ();
cout <<"Enter A: ";
cin >>a;
cout <<"Enter B: ";
cin >>b;
if (a>b)
{
cout <<"A is Greater";
}
else
{
cout <<"B is Greater";
}
getch ();
}

Find Area of Rectangle in C++


// Write a Program to find Area of Rectangle

#include <iostream.h>
#include <conio.h>
void main ()
{
int area,l,b;
clrscr ();
cout <<"Enter Length: ";
cin >>l;
cout <<"Enter Breadth: ";
cin >>b;
area=l*b;
cout <<"\n Area is: "<<area;
getch ();
}

Volume of Box in C++


//Write a program to find volume of box
#include <iostream.h>
#include <conio.h>
void main ()
{
int area,l,b,h;
cout <<"Enter Length, Breadth and Height: ";
cin >>l >>b >>h;
area=l*b*h;
cout <<"Area is: "<<area;
getch ();
}