Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What's wrong with the program although when n=3 the output is correct but when n=10 the output is negative topltask3-04.cpp -Dev-C++ 5.11 iew Project Execute

image text in transcribed
image text in transcribed
What's wrong with the program although when n=3 the output is correct but when n=10 the output is negative
topltask3-04.cpp -Dev-C++ 5.11 iew Project Execute Tools AStyle Window Help bals) task1-04.cpptask2-04.cppl task3-04.cpp|www.cpp 1 #include 2 int 3 main (void) ug int n,k,i-1j double sum-e printf("Enter n "); scanf ("Xd",8n) if (nk-e I n> 15) printf("ERROR) else 5 6 9 10 12 13 14 for (k-likc= nsk++) 15 16 17 18 19 20 21 sum sum 2*(i)sl i = i*10 + 1; 23 24 F 25 26 27 28 29 F 30 printf("the sun is %.elf" , sun); Write a program to compute the sum of the following series with n terms. Sum- 2 + 22+222+2222+... The program reads the values n from the user. If n or n> 15, it displays an appropriat and terminates. Otherwise, it computes and displays the sum. Note: make your sum and your terms of type double but print the sum without digits after de Enter n:1 is out of range Enter n3 sum of series for 3 terms is 246 Enter n:10 sum of series for 10 terms is 2469135800

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions