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

answered Feb 7, 2018 by anonymous

dhhanpal singh

answered Feb 9, 2018 by (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;
answered Feb 14, 2018 by Attila

// For C language

#include <stdio.h>

int main()
{
int i=0, a=0, t;        //use _t_ 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 t=2 t=4 etc.
printf("%d\n",t[i]);    //not needed, just for checking in terminal
i++;                    //here you increment the (i) index, this cause t t t 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;
}