Thursday, 20 August 2015

Armstrong number.

Write a program to print out all Armstrong numbers between 1 and 500. If sum of cubes of each digit of the number is equal to the number itself, then the number is called an Armstrong number. For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 *5 ) + ( 3 * 3 * 3 )

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d,e,f,res,num=1;
clrscr();
printf("Armstrong Numbers from 1 to 500\n");
while(num<=500)
{
a=num%10;
b=num/10;
c=b%10;
d=b/10;
e=d%10;
f=d/10;
if(num==(a*a*a)+(c*c*c)+(e*e*e))
{
printf("\n%d",num);
}
num++;
}
getch();
}

Motivational thought

Agar Log Sirf Jarurat Pe Aapko Yaad Karte Hai,
To Bura Mat Maniye, Garv Mehsus Kare,

‘Kyuki Aap 1 Roshni Ki Tarah Tab Yaad Aate Ho Jab Andhera Hota Hai..’

Tuesday, 18 August 2015

Wap to find the enter number is odd or even

#include<stdio.h>
#include<conio.h>

int main()
{
int x;
clrscr();
printf("enter any number");
scanf("%d",&x);

if(x%2==O)
printf("enter number is even");

else
printf("enter number is odd");

return 0;
}