You are on page 1of 1

C continue:

The continue statement skips the current iteration of the loop and continues
with the next iteration. Its syntax is:

continue;
The continue statement is almost always used with the if...else statement.

Example 2: continue statement


// Program to calculate the sum of numbers (10 numbers max)
// If the user enters a negative number, it's not added to the result

#include <stdio.h>
int main() {
int i;
double num, sum = 0.0;

for (i = 1; i <= 10; ++i) {


printf("Enter a n%d: ", i);
scanf("%lf", &num);

if (num < 0.0) {


continue;
}

sum += number; // sum = sum + num;


}

printf("Sum = %.2lf", sum);

return 0;
}

This study source was downloaded by 100000805187466 from CourseHero.com on 06-14-2022 04:01:14 GMT -05:00

https://www.coursehero.com/file/77657359/C-programming-Continue-statementtxt/
Powered by TCPDF (www.tcpdf.org)

You might also like