Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do you make a code that counts up by 2s?

0 votes
asked Nov 14, 2017 by anonymous

3 Answers

0 votes
answered Feb 7, 2018 by anonymous

dhhanpal singh

0 votes
answered Feb 9, 2018 by Jake Swink (140 points)
Depending on the langauge that you are writing in... but here is some psedu-code

For (int num; add 2; while num is >0)

return num;
0 votes
answered Feb 14, 2018 by Attila

// For C language

#include <stdio.h>

int main()
{
    int i=0, a=0, t[20];        //use _t[20]_ for example if you need 20 element
    while(i<20)                 //use _i<20_ for example if you need 20 element
    {
        if(!(a%2))              //here you can set the "by 2s" part, _if(!(a%3))_ is for "by 3" etc. [you can write _if((a%2)==0)_ instead of _if(!(a%2))_ aswell]
        {
        t[i]=a;                 //here you load into the t[] array on (i)th index the actual value (a) that is OK for your criterion (above if part); now t[0]=0 t[1]=2 t[2]=4 etc.
        printf("%d\n",t[i]);    //not needed, just for checking in terminal
        i++;                    //here you increment the (i) index, this cause t[0] t[1] t[2] etc (not overloading into one index every value, just step it forward in the array)
        }
    a++;                        //here you increment the value to get bigger and bigger numbers
    }

    return 0;
}

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...