Pages

Showing posts with label number. Show all posts
Showing posts with label number. Show all posts

Monday, February 16, 2015

C program to find whether a number is an Armstrong number or not

C++ program to find whether a number is an Armstrong number or not

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

void main()
{
clrscr();
int n,m=0,x,y;
cout<<"Enter any three digit numnber:";
cin>>n;
y=n;

while(n!=0)
{
x=n%10;
m+=pow(x,3);
n=n/10;
}

if(y==m)
cout<<"The number is an Armstrong number";
else
cout<<"The number is not an Armstrong number";
getch();
}
Read more »

Tuesday, February 10, 2015

C Program to calculate square root of any number

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float sq,n;
cout<<"Enter any number:";
cin>>n;
sq=sqrt(n);
cout<<"Square root of "<<n<<" is "<<sq;
getch();
}
Read more »