C program to print lengh of an array (program 20)

/*
Made by Anmol main
Student :B.tech CSE 
Punjabi university Patiala
Program No.:20
*/
#include <stdio.h>
int arr[] = {3, 2, 6, 5, 9, 4, 9, 7, 2, 6, 4, 7, 1, 3, 2, 5, 9, 8};
int main()
{
    int i, j;
    int s, p, q;
   //Logic : sizeof(name of array)/sizeof(name of array[0])
    s = sizeof(arr);
    p = sizeof(arr[0]);
    q = s / p;
    printf("\nThere are total %d elements are there in array.\n", q);
    return 0;
}

Comments

Popular posts from this blog

Glowing-Log-in-window-in-Pure-html-css #30

Mouse Hover Effect in Html CSS and Javascript #27

Recipie book in c language with text animiations - Source code ( Program - 18 )