Results 1 to 2 of 2

Thread: C code for given number is Armstrong number or not

  1. #1
    RussellBarnes is offline Senior Member
    Join Date
    Dec 2009
    Posts
    214
    Rep Power
    3

    Default C code for given number is Armstrong number or not

    Hi. I am learning C programming language. I practice different program but I am little bit confuse in code for Armstrong number. Please explain me how’s the code work with suitable example. All possible replies and suggestions are appreciated.

  2. #2
    PetersonClark is offline Senior Member
    Join Date
    Dec 2009
    Posts
    202
    Rep Power
    3

    Default

    I suggest you to refer following example of Armstrong number, which will give you something idea about the use of this:

    Code:
    void main()
    {
    int n,b=0,t;
    clrscr();
    printf(“Enter the no”);
    scanf(“%d”,&n);
    t=n;
    while(n>0)
    {
    a=n%10;
    b=b+a*a*a;
    n=n/10;
    }
    if(b==t)
    {
    printf(“Armstrong no”);
    }
    else
    {
    printf(“Not an Armstrong no”);
    }
    getch();
    }

Similar Threads

  1. Java code palindrome number
    By AllenBrown in forum Programming
    Replies: 2
    Last Post: 06-14-2010, 02:18 PM
  2. Code for sum of odd number and even number separately in c
    By EvansMitchell in forum Programming
    Replies: 2
    Last Post: 05-10-2010, 02:06 PM
  3. Explanation of Error code number 10 generated by XP
    By Dexter Hogg in forum Windows XP
    Replies: 0
    Last Post: 07-11-2009, 01:19 PM
  4. Number of USB connections
    By taisikao in forum Everything Else
    Replies: 0
    Last Post: 07-02-2008, 10:40 AM
  5. Network number
    By Newtech32 in forum General Internet Terms
    Replies: 0
    Last Post: 04-01-2008, 10:04 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48