In this c++ program, explain every line of this program. Please thank you Source Code: #include using namespace std; int main() {     //printing the statements as mentioned     cout<<"The function is f(x)= 2x+3(2)"<<"\n";     cout<<"Width is 0.05"<<"\n";     //declaring variables of float datatype     float lowLim,upperLim;     //asking user for input     cout<<"Enter Lower Limit: ";     //taking input for lowLim     cin>>lowLim;     //asking user for input     cout<<"Enter Upper Limit: ";     //taking input for upperLim     cin>>upperLim;     //declaring variables iterations,initAns,i     float iterations,initAns,i;     //calculating number of iterations     iterations=(upperLim-lowLim)/0.05;     //declaring i=0     i=0;     //declaring variable finAns of float datatype     float finAns=0;     //loop for iterations     while(i

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In this c++ program, explain every line of this program. Please thank you

Source Code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    //printing the statements as mentioned
    cout<<"The function is f(x)= 2x+3(2)"<<"\n";
    cout<<"Width is 0.05"<<"\n";
    //declaring variables of float datatype
    float lowLim,upperLim;
    //asking user for input
    cout<<"Enter Lower Limit: ";
    //taking input for lowLim
    cin>>lowLim;
    //asking user for input
    cout<<"Enter Upper Limit: ";
    //taking input for upperLim
    cin>>upperLim;
    //declaring variables iterations,initAns,i
    float iterations,initAns,i;
    //calculating number of iterations
    iterations=(upperLim-lowLim)/0.05;
    //declaring i=0
    i=0;
    //declaring variable finAns of float datatype
    float finAns=0;
    //loop for iterations
    while(i<iterations)
    {
        //printing in required format
        cout<<"_________________________________________________________________________________________________________________________________\n";
        //printing Iteration number
        cout<<"Iteration: "<<i+1<<"\n";
        //printing upper and lower limit of present Iteration
        cout<<"Function\t\t|\tLower Limit \t|\t Upper Limit \t|\t LRAM Application (width=0.05) \t|\t Answer\n";
        //calculating value of initAns
        initAns=((2*lowLim)+(3*2))*0.05;
        //printing values of lowLim,Upper limit,value of function and answer for this Iteration
        printf("f(x)= 2x+3(2) \t\t|\tx= %.2f\t\t|\tx=%.2f\t\t|\t f(x) = (2(%.2f)+3(2) * 0.05\t|\t  %.2f\n",lowLim,lowLim+0.05,lowLim,initAns);
        //adding value of this iteration to the final answer
        finAns+=initAns;
        //incrementing value of lowLim by 0.05
        lowLim+=0.05;
        //incrementing i by 1
        i+=1;
    }
    //printing in required format
    cout<<"_________________________________________________________________________________________________________________________________\n";
    //printing final answer to the console
    printf("Final answer/Summation of all iterations is: %f\n",finAns);
    return 0;
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education