Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Intro to Arrays with comments
//gcc 5.4.0 #include <stdio.h> void main(void) { int sum = 0; int n = 10; int scores[10]={9,20,30,40,51,60,70,80,90,100}; //initializes the array and enters in the values// for (int i=0; i<n; i++){ //classic "for" loop statement that uses i as the counter and every time the i counts a value in the arraty// if (scores[i]%2==0){ //if statement checks if certain "i" element of array is divisable by 2 (USE THE DOUBLE EQUAL SIGN!!!)// printf("Scores[%d]=%d\n", i, scores[i]); //prints the certain "i" values from the array before incrimenting the "i" BUT ONLY PRINTS DVISABLE BY 2// } sum+=scores[i]; //Sums all scores (divisable by 2 or not)// printf("Sum of values = %d\n", sum); //prints sum of all numbers because print sum statement// } }
run
|
edit
|
history
|
help
0
Prgm
Project 4 v.3
sum of arrays
Project 5 v.02
variable number of arguments 3
Assignment 2
FILE Access 2
C programming example that implements a modified string length function (from ECE 2534)
domain.com
Project v0.12