how to optimize this code in c?

int j=4,k=4;

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

{
j+ =i:

k-=i:
}

Recommended Answers

All 4 Replies

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.

[deleted]

Be a part of the DaniWeb community

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