Question: #include #include #define N 1 0 / / Line 1 int main ( ) { unsigned char i; char * d; unsigned char sum =

#include
#include
#define N 10// Line1
int main(){
unsigned char i;
char* d;
unsigned char sum =0;
d =(char*)malloc(N * sizeof(char));
for (i =0; i < N; i++)*(d + i)= i;
for (i =0; i < N; i++) sum +=d[i];
free(d);
printf("sum is %d
", sum);
}
(1) what is the value printed by the printf() statement?
(2) If #define N 100 is used instead of Line 1, would sum have the intended result? If not, how would you fix that problem?
(3) If #define N 1000 is used instead of Line 1, what problem would additionally emerge? How would you fix those problems?
(1) what is the value printed by the printf() statement?
(2) If #define N 100 is used instead of Line 1, would sum have the intended result? If not, how would you fix that problem?
(3) If #define N 1000 is used instead of Line 1, what problem would additionally emerge? How would you fix those problems?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!