Home  |  IT Zone  |  Tips / Tricks  |  Did You Know  |  Inspirational  |  Health  |  World Infos  |  Insurance  |  Universities  |  Forex  |  Mathematics  |  Illusions  |  Children Day Quotes  |  Fun / Jokes  |  Decent Quotes  |  Birthday Msgs  |  Good Morning Msgs  |  Good Night Msg  |  Husband Wife Jokes  |  Teacher Students Jokes  |  Insult Jokes  |  Love Quotes  |  Sad Quotes  |  Funny Pics  |  Be Aware  |  Articles  |  Simple Joys of Life 

To Find The Sum From 1 to N (Qbasic Code)

To Find The Sum From 1 to N (Qbasic Code)
  • CLS
    INPUT "Enter the number upto which you want to add"; n
    s = 0
    FOR i = 1 TO n
        s = s + i
    NEXT i
    PRINT "The sum is "; s
    END

 Next Method (Using DO WHILE ... LOOP)
  •  CLS
    INPUT "Enter the number upto which you want to add"; n
    s = 0
    c = 1
    DO WHILE c <= n
        s = s + c
        c = c + 1
    LOOP
    PRINT "The sum is "; s
    END

Share :

Twitter
Back To Top

facebook main

Powered by Blogger.