Printing Arrays in separate Function in C -
i'm trying print of values in 4 arrays sending them separate function. problem can't function print of integers in array because i'm not sure set true false statement in 'for' loop to, universal array of size.
right function prints first 11 numbers assume that's because first number in array 11.
#include <stdio.h> void print_array(int a[]); void find_max(int b[]); void find_min(int c[]); void search(int d[]); void sort(int e[]); int main(void) { int first[11] = {7,7,7,7,7,7,7,7,7,7,7}; int second[14] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2}; int third[16] = {-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; int fourth[23] = {-3, 4, 33, 22, 9, -100, 2, 56, 57, 55, 2, 90, 2234, 32, 8, 123, 2, 33, 22, 22, 33, -1, -3}; print_array(&second[0]); return(0); } void print_array(int a[]) { int i; for(i=0;i<*a;i++) { printf("%d ",a[i]); } }
pass second argument function takes length of array. example:
print_array(int *array, int length) { (int = 0; < length; i++) { /* whatever */ } }
Comments
Post a Comment