I have initialized an array of size 10 but on printing the sizof array shows 40 . The code is as follows ,
#include <iostream> using namespace std; int main() { int arr[10] = {2,4,5,6,7,8,9,6,90}; printf("%d \n" , sizeof(arr)); } Output :
/Users/venkat/Library/Caches/CLion2016.1/cmake/generated/InsertionSort-e101b03d/e101b03d/Debug/InsertionSort 40 Process finished with exit code 0 What does C prints 40 here ?
printf("%zu\n" , sizeof(arr) / sizeof(arr[0]);.%dis used forint.using namespace std;is not valid standard C code.