Write a program to find the length of the array
Example:
Input: arr[]={2,3,5,1,3} Output: 5
Approach
C
#include <stdio.h>int main(){int arr[] = {2, 3, 5, 1, 3};int len = sizeof(arr) / sizeof(arr[0]);printf("Size of array is %d", len);return 0;}
Java
public class Main{public static void main(String[] args) {int[] arr = {2,3,5,1,3};System.out.println("length of array "+ arr.length);}}
No comments:
Post a Comment