In the following program, the structure object nd[0] node consumed 8 bytes of memory. Ideally, nd[0] should consume 5 bytes of memory in total. I mean, 4 bytes for Int type + 1 byte for the char type.
Output : 8 1 4Code:#include<iostream> #include<stdio.h> using namespace std; struct Node { int distance; char charName; } nd[] = {5,'b'}; int main() { cout << sizeof(nd[0]) << " " << sizeof(nd[0].charName) << " " << sizeof(nd[0].distance) << endl; return 0; }