Ask Experts Questions for FREE Help !
Ask
    jercee's Avatar
    jercee Posts: 1, Reputation: 1
    New Member
     
    #1

    Oct 15, 2013, 07:21 AM
    Algorithm
    Write an algorithm to find the first 50 natural numbers
    Celine91's Avatar
    Celine91 Posts: 51, Reputation: 9
    Junior Member
     
    #2

    Oct 16, 2013, 03:52 PM
    A very simple c++ code can be :

    #include <iostream>
    using namespace std;
    int main()
    {

    for (int i =0; i<49; i ++)
    {
    cout<<i<<" ";
    }

    return 0;
    }

    --------------------------------------------------
    if you only want a general algorithm to read the first n natural numbers:

    1. Read n
    2. Initialize N = 0
    3. Calculate N = N+1
    4. If N> n-1, stop
    5. Write N

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Pseudocode algorithm [ 5 Answers ]

Does any of you know how to write pseudo code algorithm?

Algorithm Inquiry [ 1 Answers ]

I have an amount of $1.85 that I have to convert into quarters, dimes, nickels and pennies. The following is what I have come up with: Q = Amount/25 Amount = Amount - 25 * Q D = Amount/10 Amount = Amount - 10 * D N = Amount/5 Amount = Amount - 5 * N

Program and algorithm [ 1 Answers ]

HI ,, CUD ANYONE GIVE ME A WORKING ALGORITHM AND PROGRAM IN C ABOUT LCM AND MODE , MEDIAN ,,AND HCF,, IT SHULD WORK IN LINUX OS TOO.. THANK..U..:o :)

Structure of the algorithm [ 2 Answers ]

Write a set of instructions using while loop and if... else Selection structures to sort the pile of cards according to the Symbols they display and write an appropriate message for each Card, for example 'shaded circle' or 'unshaded square'. Each Message should be on a new line. The...


View more questions Search