Develop a C program to initialize the array statically and display its elements
Code
#include <stdio.h>int main(){//Initialize arrayint arr[] = {1, 2, 3, 4, 5};//Calculate length of arrayint length = sizeof(arr)/sizeof(arr[0]);printf("Elements of given array: \n");//Loop through the array by incrementing value of ifor (int i = 0; i < length; i++) {printf("%d\n", arr[i]);}return 0;}
Output
0 Comments
Post a Comment