#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int year;
cout<<"\nEnter the year:";
cin>>year;
if(year%4==0)
cout<<"\nIt is a leap year";
else
cout<<"Not a leap year";
getch();
}
8
Output :
9
// 5. Program to implement if-else if ladder statement
// 8. Program to implement do while and it computes the factorial of a number
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num,fact=1;
cout<<"\nEnter the numnber : ";
cin>>num;
do
{
fact=fact*num;
num--;
}
while(num!=0);
cout<<"\nFactorial :"<<fact;
getch();
}
16
Output :
17
// 9. Program to display an array
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[5],i;
cout<<"\nEnter the elements in an array :\n";
for(i=0;i<5;i++)
{
cin>>a[i];
}
cout<<"\nDisplayed array : \n";
for(i=0;i<5;i++)
{
cout<<"\n"<<a[i];
}
getch();
}
18
Output :
19
// 10. Program to display multiples of a number using for loop
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,num;
cout<<"\nEnter the number :";
cin>>num;
cout<<"The multiples are :";
for(i=1;i<=10;i++)
{
cout<<"\n"<<num*i;
}
getch();
}