-
Notifications
You must be signed in to change notification settings - Fork 17
/
hw9final.c
39 lines (35 loc) · 1.1 KB
/
hw9final.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*Programmer: Chase Singhofen
Date:
Specification: Array’s Introduction
*/
//preprocessors
#include <stdio.h>
#include <stdlib.h>
#define SIZE 50
//main function.
//printf(enter number and (-1 = quit )
//use for and if statements 2 each, one for input and one for output.
main() {
int number[SIZE];// size is [50]
int i;// should be in []along with variable int.
for (i = 0; i < SIZE; i++) //remember to put value = 0 with the integer [i] in for loop statement.
{
printf("enter a value for array (-1 to quit)\n\n");
scanf_s("%i", &number[i]);
if (number[i] == -1) {
break; //break the for loop and no more inputs..
}
}//end for statement
for (i = 0; i < SIZE; i++)
{
printf("%i, %i\n", i + 1, number[i]);
if (number[i] == -1) {
break;//break the for loop and no more outputs will be allowed..
// the break statements will not allow anymore input numbers to be entered.
//This will automatically display all input numbers [50] that were entered.
//SIZE value is [50].
}
}//end for and if statements.
//end main function
system("pause");
}