Showing posts with label Computer Science. Show all posts
Showing posts with label Computer Science. Show all posts

Wednesday, 7 May 2014

Armstrong Number Check

Armstrong Number Check



Armstrong Number is a three digit number such that the sum of the cubes of the digits of the number is equal to the number itself,
i.e, xyz = x3+y3+z3
Eg, 153 = 13+53+33

Given below is a program for a Armstrong number test using C++:
You can however write the code in a different way. This is just a sample.

Open C++

Write the code:
#include <stdio.h>

#include <conio.h>
void main ()
{
int x,m,sum,temp;
sum=0;
printf ("Enter number\n");
scanf ("%d",&x);
temp=x;
while (x>1)
{m=x%10;
x=x/10;
sum=sum+(m*m*m);}
if (sum==temp)
{printf ("\n%d is an Armstrong Number",temp);}
else {printf ("\n%d is not an Armstrong Number",temp);}
}

Run the code.
It works.
To save, use extension .cpp
Thanks!
ConnectU Edu.



TO KNOW MORE OR TO CLARIFY YOUR DOUBTS ON THE TOPIC, PUT A COMMENT.REMARKS, SUGGESTIONS AND QUERIES ARE WELCOME. JUST PUT A COMMENT.

Click here to download the Armstrong Number Checker Program for FREE

Monday, 30 December 2013

Check Prime Number or Not With Just 1 Click

Check Prime Number or Not With Just 1 Click

You're given a number. Will you be able to say if the number is a prime number or not?

Now, check if the number is prime or not with just one click.
No extra efforts wasted.
Given below is a program for a prime number test using C++:
You can however write the code in a different way. This is just a sample.

Open C++

Write the code:

#include <stdio.h>

#include <conio.h>
void main ()
{
int half,x,state,temp;
printf ("Enter the number\n");
scanf ("%d",&x);
half=x/2;
state=1;
temp=2;
while (state!=0&&temp<=half)
{if (x%temp==0)
{state=0;}
else {++temp;}
}
if (state==0)
{printf ("\n%d is not prime\n",x);}
else {printf ("\n%d is prime\n",x);}
}

Run the code.
It works.
To save, use extension .cpp
Thanks!
ConnectU Edu.

TO KNOW MORE OR TO CLARIFY YOUR DOUBTS ON THE TOPIC, PUT A COMMENT.REMARKS, SUGGESTIONS AND QUERIES ARE WELCOME. JUST PUT A COMMENT.
Click here to download the Prime Number Checker Program for FREE

Sunday, 29 December 2013

How To Make Your Own Multiplication Table

How To Make Your Own Multiplication Table


You need not memorize all the multiplication tables now. Just one click and the desired table appears on screen.
Learn how to make your own multiplication table using C++ language.

Given below is a code that runs the multiplication table program.
You can however, make desired changes in your program.

Open C++
Write the code:

#include <stdio.h>
#include <conio.h>
void main ()
{
int x,y;
y=1;
printf ("Enter the number whose table you want\n");
scanf ("%d",&x);
for (int i=y; i<=10; ++i)
{printf ("%d X %d = %d\n",x,i,x*i);}
}

Run the code.
It works.
To save, use extension .cpp
Thanks!

ConnectU Edu.


TO KNOW MORE OR TO CLARIFY YOUR DOUBTS ON THE TOPIC, PUT A COMMENT.
REMARKS, SUGGESTIONS AND QUERIES ARE WELCOME. JUST PUT A COMMENT.

Click here to download the Multiplication Table Program for FREE