1. Calculate the value of a function y=2x^2+15 with x varying from 1 to 20 in increments of 0.5.
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
double x;
double y;
for(x=1;x<=20;x+=0.5){
y=2*pow(x,2)+15;
cout<<"Value is: "<<y<<endl;
}}
Comments
Leave a comment