Program to implement break statement.
#include <stdio.h>
#include <conio.h>
int main()
{
#include <conio.h>
int main()
{
int i;
double number, sum = 0.0;
double number, sum = 0.0;
for (i=1; i <= 10; ++i)
{
printf ("Enter a n%d: ", i);
scanf ("%lf", &number);
{
printf ("Enter a n%d: ", i);
scanf ("%lf", &number);
// If user enters negative number, loop is terminated
if (number < 0.0)
{
break;
}
sum += number; // sum = sum + number;
}
if (number < 0.0)
{
break;
}
sum += number; // sum = sum + number;
}
printf ("Sum = %.2lf", sum);
return 0;
}
}