Friday 20 November 2009

C questions and answer with explanation




1. PERFECT NUMBER.
void main()
{
  int n,i=1,sum=0;
  clrscr();
  printf("\nEnter a number:-");
  scanf("%d",&n);
  while(i  {
            if(n%i==0)
            sum=sum+i;
            i++;
  }
    if(sum==n)
            printf("\nThe no %d is a perfect number",i);
    else
            printf("\nThe no %d is not a perfect number",i);
  getch();
}
2. ARMSTRONG NUMBER.
void main()
{
  int 

No comments:

Post a Comment