how to optimize this code in c?

int j=4,k=4;

for(i=0;i<1000:i++)

{
j+ =i:

k-=i:
}

The first question is always why do you need to optimize it?

What are the values of j and k when that code has run?

You are optimizaing this loop because you ran a profiler and too much time is being spent there, right?

Otherwise DON'T optimize.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.