Question: Q 2 . ( a ) The following listing is for a complete C program which attempts to print the sum of all integers between
Qa The following listing is for a complete C program which attempts to print the sum of all integers between and n inclusive which are divisible by but not by or However, it contains some errors in syntax and logic. List the errors, and for each error identified, explain briefly what the problem is and give the correct code. #include float mainvoid int i n sum; printfEnter the number to be processed: ; scanfd n; for i ; i n; i ifi && i sumi; printfThe sum is
∑ return; b Explain the effect of the following line of code: #define SQUARExxx How does the use of the macro SQUAREx in a C program differ from the use of the function func with definition int funcint x returnxx; Write a definition of the macro MAXab which can be used to place the maximum of two numbers a and b into a line of code such as output MAXab; c Assume that the file input.dat contains only a single word. Write a C program which reads the word from the file input.dat and then writes this word, followed by its length, to the file output.dat. You should remember to close the file properly after writing.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
