Posts

Showing posts from January, 2016

C Program to Check Armstrong Number

C Program to Check Armstrong Number: A positive integer is called an Armstrong number if the sum of cubes of individual digit is equal to that number itself . example: 7 = 7^1 371 = 3^3 + 7^3 + 1^3 (27 + 343 +1) 8208 = 8^4 + 2^4 +0^4 + 8^4 (4096 + 16 + 0 + 4096). 1741725 = 1^7 + 7^7 + 4^7 + 1^7 + 7^7 + 2^7 +5^7 (1 + 823543 + 16384 + 1 + 823543 +128 + 78125) /* C program to check whether a number entered by user is Armstrong or not. */ #include <stdio.h> int main() {   int n, n1, rem, num=0;   printf("Enter a positive  integer: ");   scanf("%d", &n);   n1=n;   while(n1!=0)   {       rem=n1%10;       num+=rem*rem*rem;       n1/=10;   }   if(num==n)     printf("%d is an Armstrong number.",n);   else     printf("%d is not an Armstrong number.",n); }

C Program to Display Character from A to Z Using Loop

C Program to Display Character from A to Z Using Loop * C program to display character from A to Z using loops. */ #include <stdio.h> int main () { char c ; for ( c = 'A' ; c <= 'Z' ; ++ c ) printf ( "%c " , c ); return 0 ; }