Answer:
C++ code explained below
Step-by-step explanation:
SOURCE CODE:
*Please follow the comments to better understand the code.
#include <stdio.h>
int numOfBytes(char* string)
{
// initialise the variables
int i=0,size=0;
// while the string reaches to \0, repeat the loop.
while(string[i]!='\0')
{
// add that size
size += sizeof(*string);
// increase the i value.
i++;
}
// add 1 byte for \0
size = size+1;
return size;
}
int main() {
char name[]="Praveen Kumar Reddy";
printf("The size is %d bytes.",numOfBytes(name));
return 0;
}
=============