#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
const float pi=3.14;
const float e=2.71828;
int main()

    int r,h;
    double A,E1,E2;
    cout<< "please enter two positive integers for r and h: "<<endl;
    cin>>r>>h;
    A=(2*pi*r*r+2*r*r*h);
    E1=(pow(e,h))+(3*(log10(A)));
    E2=sqrt(abs(cos(pow(r,2.0)+sin(pow(r,2.0)));
    cout<<"Radius      Height      Area      E1      E2"<<endl;
    cout<<fixed<<setprecision(2)<<showpoint;
    cout<<"======      ======      ====      ==      =="<<endl;
    cout<<setw(6)<<r<<setw(12)<<h<<setw(10)<<A<<setw(8)<<E1<<setw(8)<<E2<<endl;

    return 0;
}

Error list:

Warning 1 warning C4305: 'initializing' : truncation from 'double' to 'const float'
Warning 2 warning C4305: 'initializing' : truncation from 'double' to 'const float'

what could i do ?

Hi sunshine102030, welcome! :o)
Instaed of float on lines 5 and 6, use double.

Hi ddanbe,
thanks ,I tried, but it is still wrong

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
const float pi=3.14;
const float e=2.71828;
int main()
{
    float r,h;
    double A,E1,E2;
    cout<< "please enter two positive integers for r and h: "<<endl;
    cin>>r>>h;
    A=(2*pi*r*r+2*r*r*h);
    E1=(pow(e,h))+(3*(log10(A)));
    E2=sqrt(abs(cos(r*r)+sin(r*r)));
    cout<<"Radius      Height      Area      E1      E2"<<endl;
    cout<<fixed<<setprecision(2)<<showpoint;
    cout<<"======      ======      ====      ==      =="<<endl;
    cout<<setw(6)<<int(r)<<setw(12)<<int(h)<<setw(10)<<A<<setw(8)<<E1<<setw(8)<<E2<<endl;

    return 0;
}

I made these changes and i think it is correct , but they ask us to convert r^2 in the functions sin and cos to radians
so who i can do that ?

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
const float pi=3.14;
const float e=2.718281828;
int main()
{
    float r,h;
    double A,E1,E2;
    float rad;
    cout<< "please enter two positive integers for r and h: ";
    cin>>r>>h;
    A=(2*pi*r*r)+(2*pi*r*h);
    E1=(pow(e,h))+(3*(log10(A)));
    rad=((r*r)*pi)/180;
    E2=sqrt(abs(cos(rad)+sin(rad)));
    cout<<endl;
    cout<<"  Radius      Height      Area      E1      E2"<<endl;
    cout<<   fixed<<setprecision(2)<<showpoint;
    cout<<"  ======      ======      ====      ==      =="<<endl;
    cout<<   setw(8)<<int(r)<<setw(12)<<int(h)<<setw(10)<<A<<setw(8)<<E1<<setw(8)<<E2<<endl;
    cout<<"  ============================================"<<endl;
    return 0;
}

i solve the problem , thanks.

Try
const double pi=3.14;
const double e=2.718281828;
instead. That's what ddanbe was trying to tell you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.