Find Large Do While

# Find Large Do While - do //move while here and erase...

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

//while/do loop to find large until -999 is entered #include <stdio.h> //while loop void main() { int num,big; printf("Enter a number "); scanf("%d",&big); printf("Enter a number, -999 to quit "); scanf("%d",&num); while(num!=-999) //erase line and insert "do" here to make do loop { if(num>big) big=num; printf("Enter a number, -999 to quit "); scanf("%d",&num); } //move while here to make do loop printf("The largest number is %d\n",big); } /* do loop #include <stdio.h> void main() { int num,big; printf("Enter a number "); scanf("%d",&big); printf("Enter a number, -999 to quit "); scanf("%d",&num);
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: do //move while here and erase "do" to make into a while loop { if(num>big) big=num; printf("Enter a number, -999 to quit "); scanf("%d",&num); } while(num!=-999); printf("The largest number is %d\n",big); } */ /* Enter a number 1 Enter a number, -999 to quit -54 Enter a number, -999 to quit -624 Enter a number, -999 to quit 65 Enter a number, -999 to quit 95123 Enter a number, -999 to quit 56525 Enter a number, -999 to quit 100006 Enter a number, -999 to quit -999 The largest number is 100006 Press any key to continue . . . */...
View Full Document

## This note was uploaded on 10/05/2011 for the course CS 36 taught by Professor Sethhochwald during the Spring '09 term at Irvine Valley College.

Ask a homework question - tutors are online