Testing Armstrong Number

Rem Number which is equal to the sum of cube of its digits is said to Armstrong Number
CLS
INPUT "Enter testing number=";n
v=n
WHILE V<>0
  r = v MOD 10
  s=s+r^3
  v=int(v/10)
WEND
IF n=s THEN
  PRINT n; " is Armstrong Number"
ELSE
  PRINT n; " is not Armstrong Number"
ENDIF
END

73 comments:

  1. How to find 5,40,300,2000,10000 series ?
    Please help !

    ReplyDelete
    Replies
    1. CLS
      FOR I=5 TO 1 STEP -1
      PRINT I*10^P
      P=P+1
      NEXT I
      END

      Delete
    2. CLS
      N=1
      FOR I=5 TO 1 STEP -1
      PRINT I*N
      N=N*10
      NEXT I
      END

      Delete
    3. This comment has been removed by the author.

      Delete
    4. CLS
      INPUT "enter any number"; n
      WHILE n <> 0
      r = n MOD 10
      s = s + r ^ 3
      n = n \ 10
      WEND
      IF s = n THEN
      PRINT "the number is armstrong "
      ELSE
      PRINT "the number is not armstrong"
      END IF
      END
      what is wrong with this program plz tell me

      Delete
    5. After input u should take n=n1 and after wend
      If s=n1

      Delete
    6. You don't.
      Its beyond it's capacity

      Delete
    7. it display all number not a armstrong number

      Delete
    8. CLS
      B=1
      FOR A=5 TO 1 STEP-1
      PRINT A*B;
      B=B*10
      NEXT A
      END


      Delete
    9. CLS
      INPUT "enter any number"; n
      WHILE n <> 0
      r = n MOD 10
      s = s + r ^ 3
      n = n \ 10
      WEND
      IF s = n THEN
      PRINT "the number is armstrong "
      ELSE
      PRINT "the number is not armstrong"
      END IF
      END
      what is incorrect here plz very fast

      Delete
    10. CLS
      INPUT "enter any number"; n
      m=n
      WHILE n <> 0
      r = n MOD 10
      s = s + r ^ 3
      n = n \ 10
      WEND
      IF s = m THEN
      PRINT "the number is armstrong "
      ELSE
      PRINT "the number is not armstrong"
      END IF
      END
      See the difference.

      Delete
  2. how will we write a program to print the following series where N is the input:
    1, 3, 6, 10, 15....... N terms

    ReplyDelete
    Replies
    1. CLS
      INPUT "Enter the no. of terms";N
      a=2
      For I=1 TO N STEP a
      PRINT I;
      a=a+1
      NEXT I
      END

      Delete
    2. CLS
      INPUT "Enter the no. of terms";N
      a=1

      for i=2 to N+1
      print a,
      a=a+i
      next i

      Delete
    3. cls
      input "enter number of terms";n
      a=1 :b=2
      for i=1 to n
      print a;
      a=a+b
      b=b+1
      next i
      end

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. how to print all armstrong no from 1 to 1000?

    ReplyDelete
  6. Replies
    1. Input "enter a number" ; N
      For i = 1 to N
      If N mod I = 0 Then f = f + 1
      Next i

      If f = 2 then
      Print "prime"
      Elseif f >2 then
      Print "Composite"
      Else
      Print "neither prime nor composite"
      End if

      Delete
    2. rem to find whether an input numbeer is prime or composite

      cls
      input "enter a number";n
      for i = 2 to (n-1)
      r=n mod i
      if r= 0 then
      print "composite"
      goto a:
      end if
      next i
      print "prime"
      a:
      end

      Delete
    3. Cls:x=0
      Input"enter a number ",N
      For i =1 to N
      If N mod i=0 then x=x+1
      Next i
      If i=2 then
      Print N,"is prime number "
      Else
      Print N,"is not a prime number"
      End If
      End

      Delete
  7. Print Armstrong numbers from 1 to 100

    ReplyDelete
  8. Print Armstrong numbers from 1 to 100

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. help me to generates the series of
    55555 5555 555 55 5

    ReplyDelete
    Replies
    1. cls
      a=55555
      for i=1 to 5
      print a
      a=a\10
      next i
      end

      Delete
    2. cls
      a=55555
      for i = 1 to 5
      print a
      a=(a-5)/10
      next i
      end

      Delete
  11. Wap to check whether the number is automorphic or not. Please see if you can help

    ReplyDelete
  12. Wap to check whether the number is automorphic or not. Please see if you can help

    ReplyDelete
  13. WAP to find HCF and LCM.please see if u can help me

    ReplyDelete
  14. Very informative article.Thank you author for posting this kind of article .


    http://www.wikitechy.com/view-article/c-program-to-check-armstrong-number-with-example-and-explanation



    Both are really good,
    Cheers,
    Venkat

    ReplyDelete
  15. how to do wap to the inputted number is armstrong or not

    ReplyDelete
  16. How to print the pattern
    KATHMANDU
    ATHMAND
    THMAN
    HMA
    M

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  17. How to print the pattern
    KATHMANDU
    ATHMAND
    THMAN
    HMA
    M

    ReplyDelete
  18. cls
    A$="KATHMANDU"
    c=9
    For I = 1 to 5
    Print mid$(A$,I,c)
    c=c-2
    Next I
    End

    ReplyDelete
    Replies
    1. cls
      a$="kathmandu"
      p=1
      for i= len(a$)=1 step -2
      b$=mid$(a$,p,i)
      print b$
      p=p+1
      next i
      end

      Delete
  19. Armstrong number between two numbers

    ReplyDelete
  20. Hey couldnt we find armstring number this way
    Cls
    Input "enter ur no";a$
    For i =1 to len(a$)
    C$=MID$(a$,i,1)
    D=val(c$)
    E=E+D^3
    Next i
    R$=str$(E)
    If R$=A$ then
    Print "armstrong"
    Else
    Print "not armstrong"
    End

    ReplyDelete
  21. Hey couldnt we find armstring number this way
    Cls
    Input "enter ur no";a$
    For i =1 to len(a$)
    C$=MID$(a$,i,1)
    D=val(c$)
    E=E+D^3
    Next i
    R$=str$(E)
    If R$=A$ then
    Print "armstrong"
    Else
    Print "not armstrong"
    End

    ReplyDelete
    Replies
    1. not because we don't have to print the strong

      Delete
    2. "$" sign represents string variable

      Delete
  22. What is the code of duck number in q basic???

    ReplyDelete
  23. How to display this pattern
    5 4 3 2 1
    5 4 3 2
    5 4 3
    5 4
    5

    ReplyDelete
    Replies
    1. Try out this way:
      CLS
      FOR Y=1 TO 5
      FOR X=5 TO Y STEP-1
      PRINT X;
      NEXT X
      PRINT
      NEXT Y
      END

      Delete
  24. I need Armstrong no.from range 1 to 1999 plz help.

    ReplyDelete
  25. how to Print 1 9 125 2401............10th term ||Please help me

    ReplyDelete
    Replies
    1. Cls
      a = 1
      for b= 1 to 10
      print a^b
      a = a + 2
      next
      end

      Delete
  26. Write a program to input a number and check whether the number is palindrome pr not

    ReplyDelete
    Replies
    1. CLS
      INPUT"ENTER A NUMBER=";N
      LET S = 0: P = N
      WHILE (N>0)
      D = N MOD 10
      S = S * 10 + D
      N = INT(N/10)
      WEND
      IF (S=P) THEN PRINT" PALINDROME NUMBER ="; P ELSE
      END

      Delete
  27. how to write qbasic program to print the first 15 Armstrong number.

    ReplyDelete
  28. Your definition of Armstrong number is wrong.It should be-
    The number which is equal to sum of its digits raised to the power which is equal to the number of digits is known as Armstrong number.
    1,2,3,4,5,...,9 are also Armstrong number which are not valided bu your program.

    ReplyDelete
  29. WAP to display all 3 digit armstrong numbers (i.e 100-999)

    ReplyDelete
  30. Help me to convert decimal number into binary

    ReplyDelete
  31. How to check whether the given number is a spy number or not?

    ReplyDelete
  32. How to find?
    Wap to input any number and display whether it is perfect number or not.

    ReplyDelete
  33. how to print armstrong number between 100 to 999

    ReplyDelete
  34. Another method of finding armstrong number
    Cls
    Input "Enter a number";n$
    For i=1 to len(n$)
    b=val(mid$(n$,i,1))
    c=c+b^3
    next i
    if val(n$)=c then
    Print n$;"is an armstrong number"
    else
    Print n$;"is not an armstrong number"
    end if
    end

    ReplyDelete
  35. help me with this pls
    1 ,22, 333 ,4444 ,5555

    ReplyDelete
    Replies
    1. CLS
      FOR x = 1 TO 5
      y = y + 10 ^ (x - 1)
      PRINT i * a
      NEXT
      END

      Delete
  36. Are u aloud to use v\10 instead of int(v/10)

    ReplyDelete
  37. CLS
    FOR n = 100 TO 999
    k1 = k
    WHILE c <> 0
    r = k1 MOD 10
    s = s + r ^ 3
    k1 = k1 \ 10
    WEND
    IF k1 = s THEN
    PRINT " it is an armstrong number ";
    END IF
    NEXT n
    END

    is this correct plz help me

    ReplyDelete
    Replies
    1. ELSE missing
      you should write :
      ELSE
      PRINT"It is not an armstrong number."
      (before end if)

      Delete