Sunday, 21 January 2018

Program for armstrong


#include<stdio.h>
#include<conio.h>
main()
{
int n,r,sum=0,t;
clrscr();
printf("enter the value:");
scanf("%d",&n);
t=n;
while(n!=0)
{
r=n%10;
sum=sum+r*r*r;
n=n/10;
}
if(t==sum)
{
printf("it is a armstrong");
}
else
{
printf("it is not armstrong");
}
getch();
}�

Related Posts:

  • Pointers And StringsPointers And Strings    We cannot assign a string to another,whereas we can assigna char pointer to another char pointer. This is shown with an example:main(){ char str1[]="hello"; char str2[10]; char… Read More
  • Basic PointersBasic PointersPointer Definition: Pointer is a variable which contains the address of another variable.Reasons for using pointer:1.A pointer enables us to access a variable that isdefined outside the function.2.Pointers are m… Read More
  • Two Dimensional Array Of CharactersTwo Dimensional Array Of CharactersOur example program asks you to type your name.When you do so,it checks against a master list to see if you are worthy of entry to the palace.Example:    #include "string.h"&n… Read More
  • Structures and FunctionsStructures and FunctionsThe main philosophy of C language is the use of functions.C supports the passing of structure values as arguments to function. In this ,the values of a structure can be transferred from one function to… Read More
  • Introduction To StructuresIntroduction To StructuresArrays can be used to represent a group of data items that belong to same type,such as int or float.However, If we want to represent a collection of data items of different types using a single name,… Read More

0 comments:

Post a Comment