//PROGRAM TO ENTER TEN NUMBERS AND DISPLAY THEIR SUM
#include<iostream.h>
#include<conio.h>
void main()
{
int num,i,sum=0;
clrscr();
cout<<"Enter Ten numbers "<<endl;
for(i=1;i<=10;i++)
{
cin>>num;
sum=sum+num;
}
cout<<"The sum is " <<sum<<endl;
getch();
}
//PROGRAM TO ENTER TEN NUMBERS AND DISPLAY THE BIGGEST NUMBER
#include<iostream.h>
#include<conio.h>
void main()
{
int num,i,big=0;
clrscr();
cout<<"Enter Ten numbers "<<endl;
for(i=1;i<=10;i++)
{
cin>>num;
if(num>big)
{
big=num;
}
}
cout<<"The biggest number is " <<big<<endl;
getch();
}
In the program given above you can make some modification to get the smallest of ten numbers also
//PROGRAM TO ENTER A NUMBER AND DISPLAY THE SUM OF ITS DIGITS
#include<iostream.h>
#include<conio.h>
void main()
{
int num,i,dig,sum=0;
clrscr();
cout<<"Enter a number "<<endl;
cin>>num;
for(i=num;i>0;i=i/10)
{
dig=i%10;
sum=sum+dig;
}
cout<<"The sum of all the digits is " <<sum<<endl;
getch();
}
//PROGRAM TO ENTER A NUMBER AND DISPLAY if it is an armstrong number is or not
#include<iostream.h>
#include<conio.h>
void main()
{
int num,i,dig,cube,sum=0;
clrscr();
cout<<"Enter a number "<<endl;
cin>>num;
for(i=num;i>0;i=i/10)
{
dig=i%10;
cube=dig*dig*dig
sum=sum+cube;
}
if(sum==num)
cout<<"The number is an armstrong number " <<endl;
else
cout<<"The number is not an armstrong number"<<endl;
getch();
}
//PROGRAM TO ENTER A NUMBER AND DISPLAY ITS REVERSE NUMBER
#include<iostream.h>
#include<conio.h>
void main()
{
int num,i,dig,rev=0;
clrscr();
cout<<"Enter a number "<<endl;
cin>>num;
for(i=num;i>0;i=i/10)
{
dig=i%10;
rev=rev*10+dig;
}
cout<<"The reverse number is " <<rev<<endl;
getch();
}
//PROGRAM TO ENTER A NUMBER AND CHECK IF IT IS A PALINDROME NUMBER OR NOT
#include<iostream.h>
#include<conio.h>
void main()
{
int num,i,dig,rev=0;
clrscr();
cout<<"Enter a number "<<endl;
cin>>num;
for(i=num;i>0;i=i/10)
{
dig=i%10;
rev=rev*10+dig;
}
cout<<"The reverse number is " <<rev<<endl;
if(rev==num)
{
cout<<"Palindrome Number "<<endl;
}
else
{
cout<<"Not a Palindrome number"<<endl;
}
getch();
}
// WRITE A PROGRAM TO ENTER A NUMBER AND DISPLAY IF IT IS APRIME NUMBER OR NOT
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num,i;
cout<<"Enter the number "<<endl;
cin>>num;
for(i=2;i<=num-1;i++)
{
if(num%i==0)
{
cout<<"Not a prime number"<<endl;
break;
}
}
if(i==num)
{
cout<<"The number is a prime number"<<endl;
}
getch();
}
No comments:
Post a Comment