C examples for Array:Array Element
Add 10 to each value in an array.
#include <stdio.h> int main( void ){ int elements[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int new_array[10]; for (int idx = 0; idx < 10; idx++) {//from ww w .j a va 2 s.c om new_array[idx] = elements[idx] + 10 ; } for (int idx = 0; idx < 10; idx++){ printf( "\nelements[%d] = %d \tnew_array[%d] = %d", idx, elements[idx], idx, new_array[idx] ); } return 0; }