Write a C program that will calculate the sum of every third integer by using do-while.
Answers
Answered by
1
Answer:
Using a for loop: #include<iostream> int main() int i, sum=0; for(i=2;i<=100;i+=3) { sum=sum+i; } cout<<"Sum is:"<<sum; ...
Using a while loop: #include<iostream> int main() int i=2, sum=0; while(i<=100) { sum=sum+i; i+=3; } ...
Using a do while loop: #include<iostream> int main() int i=2, sum=0; do. { sum=sum+i; i+=3; }
Similar questions