1 Write the c code to a Ask the user to input an integer sta
1) Write the c++ code to: a) Ask the user to input an integer starting value. Use a loop to validate that the number is an integer between 1 and 40. b) Ask the user to input an integer ending value. Use a loop to validate that the number is an integer greater than the starting value, but not greater than 100. c) Display a chart of all the numbers from the starting value to the ending value, along with their squares and cubes. Display output in columns.
Solution
#include <iostream>
 using namespace std;
 int main()
 {
    int s,e,i;
    cout<<\"Enter the starting value:\";
    cin>>s;
    if(s<1 || s>40)
    {
        cout<<\"The value must be between 1 and 40\"<<endl;
        return -1;
    }
    cout<<\"Enter the ending value:\";
    cin>>e;
    if(e<=s)
    {
        cout<<\"The ending value must be greater than starting value\"<<endl;
        return -1;  
    }
    if(e>100)
    {
        cout<<\"The ending value must be less than 100\"<<endl;
        return -1;      
    }
    for(i=s;i<=e;i++)
    {
        cout<<i<<\' \'<<i*i<<\' \'<<i*i*i<<endl;
    }
    return 0;
 }

