1. Engineering
  2. Computer Science
  3. this is from my c programming class all the instruction...

Question: this is from my c programming class all the instruction...

Question details

this is from my C programming class.

all the instruction are given in the picture.

please give me complete working code as it asks.

3 //when we run the code and enter n, 4 I/try 1, 10, 100, 1000, 10000, 100000, 1000000 5 //Pay attention to whether the program is giving your the correct result 6 //Note the result of sum up from 1 to n should be n* (n+1)/2 7 //You can use this formula to check the result geneated by the code. 8 //From the above inputs for n, find the minimum n that geneates a wrong result, 9//then first comment out the following part of the code from the main function. 10-/* int i, n, sum sum printf (Enter n:In) scanf(%d, &n); 12 14 15 16, 17 while (i <= n) { sum sum+ i

sum sum+i 17 18 printf(Sum from 1 to %d-%d\n, sum); 2θ 21 n, */ 23 //And then uncomment and make changes to the lines of code that follows and complie and 24 I/run the code again, and submit your work 25 //Note there might be errors in this part of the code, you need to fix them 26 27 //The reason the code breaks when n is large is because the int type is represented by 4 bytes 28 I/The maximum integer that can be represented by int is 2431 -1-2147483647 29 I/If our sum is above this number, we will get a wrong result. 30 //Note you use the following statement to show the size of int 31 //printf(The size of int is %ldin, sizeo f (int)); 32 33 / 34 Compute the sum of the integers 35 from 1 to n, for a given n 36 / 37 #include <stdio.h> 38 39 - int main(void) t 40 41 42 printf(Enter n:In); 43 scanf(%d,&n); int i, n, sum while (i n) 46 47 48 49 sumsum+1 printf(Sum from 1 to %d- %d\n, n, sum); 51 I/ int N 1000; 52 77 print(Among 1, 10, 100, 1000, 10000, 100000, 10000001n); 53 // print (The smallest number to break the code is %d\n, N); 54 return 56 57

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution