#include<stdio.h>
int add(int);
int main()
{
    int a,sum=1,c,d;
    printf("enter a number \n");
    scanf("%d",&a);
    sum=add(a);
    if(sum==a)
    printf("entered number is armstrong number");
    else
        printf("entered number is not armstrong number");

}
int add(int a)
{
     int rem,sum=0;
        while(a!=0)
         {
                    rem=a%10;
                    a=a/10;
                    sum=sum+(rem*rem*rem);
                    }

                              }

You need a method to force the user the press a key before the console is allowed to close. Here's a pretty good article that discusses the various options for that. In your case, since you seem to be using c, I would suggest this answer from that article:

void PressEnterToContinue()
{
  int c;
  printf( "Press ENTER to continue... " );
  fflush( stdout );
  do c = getchar(); while ((c != '\n') && (c != EOF));
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.