Was wondering if the 1st code snippet would produce more efficient executable code than the 2nd:
(1) int main()
{ int n,i=1;
cout << "Enter a positive integer: ";
cin >> n;
long sum=0;
while (i <= n)
sum += i++;
cout << "The sum of the first " << n << " integers is " << sum;
}
(2) int main()
{ int n,i=1;
cout << "Enter a positive integer: ";
cin >> n;
long sum=0;
while (i <= n)
{
sum += i;
++i;
}
cout << "The sum of the first " << n << " integers is " << sum;
}