I am having a problem with these questions I try differents

I am having a problem with these questions. I try differents way to get the right solution but still getting an error message. Need help?

Execute the following code and identify the errors in the program. Debug the program and provide the correct version of the code.

Execute the following code and identify the errors in the program. Debug the program and provide the correct version of the code. Hint: The value that should display for aPtr is 5.

#include k stdio.h int main() char greeting 51 t \'H\', \'e\' \'1\', \'1\', \'o\' initialize character array printf (\"InGreeting message: An Ann\", greeting); play greeting return 0 terminate program

Solution

PART 1 : You are tring to print greeting as string(%s) so at the end of greeting \'\\0\' need to be appended

CODE

#include<stdio.h>
int main()
{
char greeting[6]={\'H\',\'e\',\'l\',\'l\',\'o\',\'\\0\'};
printf(\"\ Greeting message:%s\ \ \",greeting);
return 0;
}

PART 2: You just need to provide address of a to aPtr

CODE

#include<stdio.h>
int main()
{
int a=51;
int *aPtr=&a;
printf(\"\ The value of a is %p\ \",&a);
printf(\"\ The value of *aPtr is %d\ \ \",*aPtr);
return 0;
}

I am having a problem with these questions. I try differents way to get the right solution but still getting an error message. Need help? Execute the following

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site