#include <stdio.h> #include<stdlib.h> int arr[100],n; void display(); void insert(int num,int loc); void del(int num);
Information about resetting and configuring Mobile phones (Java, Android, Symbian etc), educational articles especially for programming in C, C++ and Java and more about Computers and operating systems
Showing posts with label computer program. Show all posts
Showing posts with label computer program. Show all posts
C Program For Insertion And Deletion In Heap
C program code for Insertion and Deletion in a Heap.
C and C++ Programs to Check Whether a Given Number is Armstrong Number or Not
This post contains two programs, a C++ program and a C program. These are programs to check whether a given number is an Armstrong number or not. An Armstrong number is a positive integer for which the sum of 'n'th power of all of its digits is equal to the number itself. For example, 153 is a 3 digit Armstrong number because 13+53+33=153.
C ++ program:
C Program:
C ++ program:
# include <iostream.h> # include <conio.h> # include <math.h> void main () { clrscr(); int a,b=0,sum=0; long int n; cout<<"Enter the number to be checked\n "; cin>>n; if(n<1) { cout<<"\nThe number should be greater than 0"; } else { a=n; //counting the digits while (a>0) { a=a/10; b++; } a=n; //adding up bth power of digits while(a>0) { sum=sum+pow(( a%10) ,b); a=a/10; } if(sum==n) cout<<"\nThe number is an ARMSTRONG number"; else cout<<"\nThe number is NOT an ARMSTRONG number"; } getch(); }
C Program:
# include <stdio.h> # include <conio.h> # include <math.h> void main () { clrscr(); int a,b=0,sum=0; long int n; printf("Enter the number to check\n "); scanf("%i",&n); if(n<1) { printf ("\nThe number should be greater than 0"); } else { a=n; //counting the digits while (a>0) { a=a/10; b++; } a=n; //adding up bth power of digits while(a>0) { sum=sum+pow(( a%10) ,b); a=a/10; } if(sum==n) printf ("\nThe number is an ARMSTRONG number"); else printf ("\nThe number is NOT an ARMSTRONG number"); } getch(); }
Labels:
$ccpp
,
Armstrong
,
Armstrong numbers
,
c
,
C++
,
check
,
code
,
computer program
,
given number
,
number
,
or not
,
program
,
programme
,
programming
,
programming language
,
source code
,
whether
Subscribe to:
Posts
(
Atom
)