Do While Loop - float avg printf"Enter a number"...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//do/while loop to find sum+avg until user enters -999 //indeterministic: #of times to do the loop is not known //exit controlled: condition is at bottom, 1 minimum execution //division by zero not a problem #include <stdio.h> void main() { int num,sum=0,c=0;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: float avg; printf("Enter a number "); scanf("%d",&num); do { sum+=num; c++; printf("Enter a number, -999 to quit "); scanf("%d",&num); } while(num!=-999); avg=sum/(float)c; printf("The sum is %d\nThe avg is %f\n",sum,avg); }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online