Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /*
- *Bradley Felix, bfelix2019@my.fit.edu
- *CSE 1001, Section E2, Fall 2019
- *Project: oridnal.c
- */
- int main (void){
- //Introduction and input values
- int i, a, sum = 0;
- printf("Welcome to Oridnal numbers!\n");
- printf("Enter a value between 0 and 65535 (negative value to quit): ");
- scanf("%d", &a);
- //Checking to see if input is outside range
- while (a > 65535){
- printf("Input not allowed. Try again.\n");
- printf("Enter a value between 0 and 65535 (negative value to quit): ");
- scanf(" %d", &a);
- }
- //Start the loop
- while (a >= 0){
- while (a > 65535){
- printf("Input is not allowed. Try again.\n");
- printf("Enter a value between 0 and 65535 (negative value to quit): ");
- scanf(" %d", &a);
- }
- for (i = 0; i <= a; i++){
- printf("%d Value\n", i);
- sum += i;
- }
- printf("Enter a value between 0 and 65535 (negative value to quit): ");
- scanf("%d", &a);
- }
- printf("The sum of all your entered numbers is %d\n", sum);
- printf("Goodbye! Thanks for playing!");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement