Programming in C
description
jhjhjj
Transcript of Programming in C
Q1.TO KNOW WHETHER NUMBER IS ARMSTRONG OR NOT???void main(){int n,b=0,t;clrscr();printf(Enter the no);scanf(%d,&n);t=n;while(n>0){a=n%10;b=b+a*a*a;n=n/10;}if(b==t){printf(Armstrong no);}else{printf(Not an armstrong no);}getch();}
EXAMPLE:
153 = 1 + 5 + 3Concept is adding the cubes of individual digits we hav to get back the same whole number.Q2.TO CHECK WHETHER A GIVEN NUMBER IS PRIME OR NOT????main()
{
int i,j=2,ch=0;
clrscr();
printf("\nENTER ANY NUMBER");
scanf("%d",&i);
while(j