Code Editing

For the following part of the introduction, we will reuse the same code as you have previously seen.

#define MAXINT 200000

int main(void) 
{
    unsigned int t=1000, k=0, l=5, pn=2; 
    unsigned int primes[t];
    primes[0]=2;
    primes[1]=3;

    while (pn < t || primes[pn] < MAXINT)
    {
        for ( k = 0; k <= pn; k++)
        {
            if (l % primes[k] == 0)
			{
                goto otog;
			}
            else 
            {
                if (k == pn)
                    primes[pn++]=l;
            } 
        }
otog:
        l += 2;
    }
    return 0;
}

Atmel Studio has a rich editor that is made even richer by Microchip and third-party plugins. Atmel Studio has an automatic code generation faculty for snippets of C source code. To use it select and right click the part of the code you wish to enclose in a conditional structure (like for,while,if … etc).

Using the code snippets you can add parts to your core source. In some snippets the variable names and exit conditions are parametric within the IDE, so as if only one instance is changed all instances within the snippet will also change, such is the case of for loop.

Table 1. Using 'Surround With'