c++ - how can i call my two functions intro my main function? -


so first function multiply input pi , make inside cos, , second function multiply same input pi , make inside sin. in int main, created loop, in order store value user , cal 2 function rest, gives me error , don't know why
here code:

#include <iostream> #include<iomanip> #include <cmath> using namespace std;  double xpicos(double x) {//const double pi = 3.14159265;  double xpicos = cos(x*pi);  return xpicos;   }       double xpisin(double x)    {const double pi = 3.14159265;    double xpisin = sin(x*pi);         return xpisin;     }  int mian () {    const double pi = 3.14159265; double x=0; double y = 0;     const int capacity = 200;     double corners[capacity];     cout << "enter" ;     (int = 0; < 200; i++)     {cin >> corners[i];     double x = xpicos(corners[i]);      double y =xpisin(corners[i]);      }   cout << x << "," << y ;      return 0; } 

there's lot of errors , mistakes in code. don't need iomanip, main spelt mian, pi isn't in correct scope, re-declare x , y , cout fell out of it's for loop , wants '\n' after each line. more like:

#include <iostream> #include <cmath>  using namespace std;  const double pi = 3.14159265;  double xpicos(double x) {     double xpicos = cos(x*pi);     return xpicos; }  double xpisin(double x) {     double xpisin = sin(x*pi);     return xpisin; }  int main () {     const int capacity = 200;     double corners[capacity];      cout << "enter: " << endl;     (int = 0; < 200; i++)     {         cin >> corners[i];         double x = xpicos(corners[i]);         double y = xpisin(corners[i]);         cout << x << ", " << y << endl;     }      return 0; } 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -