Define array and use it : Array Int « Data Type « C / ANSI-C

C / ANSI-C
1. assert.h
2. Console
3. ctype.h
4. Data Structure Algorithm
5. Data Type
6. Development
7. File
8. Function
9. Language Basics
10. Macro Preprocessor
11. Math
12. math.h
13. Memory
14. Pointer
15. setjmp.h
16. signal.h
17. Small Application
18. stdio.h
19. stdlib.h
20. String
21. string.h
22. Structure
23. time.h
24. wctype.h
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C / ANSI-C » Data Type » Array IntScreenshots 
Define array and use it


#include <stdio.h>

void main()
{
  int numbers[10];                               /* Array storing 10 values     */
  int count = 10;                                /* Number of values to be read */
  long sum = 0L;                                 /* Sum of the numbers          */
  float average = 0.0f;                          /* Average of the numbers      */
  int i = 0;                                     /* Loop counter                */

  printf("\nEnter the 10 numbers:\n");           

  /* Read the ten numbers to be averaged */
  for(i = 0; i < count; i ++)
  {
    printf("%2d : ",i+1);
    scanf("%d", &numbers[i]);                    /* Read a number               */
    sum += numbers[i];                           /* Add it to sum               */
  }

  average = (float)sum/count;                     /* Calculate the average      */

  printf("Average of the ten numbers entered is: %f\n", average);
}



           
       
Related examples in the same category
1. Prints out numbers and their doubles
2. Shows two ways an array can be cleared
3. An example of how to initialize a matrix: loop
4. Array initializationArray initialization
5. Assign int value reference to int arrayAssign int value reference to int array
6. Array: assign and retrieve valueArray: assign and retrieve value
7. Output array addressOutput array address
8. Allocate memory for int arrayAllocate memory for int array
9. Declares a 100-integer array
10. Reference element in array
11. an example of using an array for two tasks
12. Int array and its pointer
13. Use for loop to calculate the square and save it to array
14. Define int array and assign value
w__w__w__.ja_v_a___2___s___.___co__m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.