Function/Table problem

solved
Last edited on
Put your code in the code tags,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<iostream>
 #include<cmath>
 #include<iomanip>
 
using namespace std;
 
int function(int x, int y)
 {
 int f;
 f=pow((pow(x,2)+pow(y,2)),.5);
 return(f);
 }
 
int main()
 {
 int x(0); // x integers
 int y(0); // y integers
 int m(0); // number of integers
 int f(0); // function (x,y)

 for (x=0; x<=m+1; x++)
 {
 for (y=1; y<=x; y++)
 {
 cout.precision(1);
 cout << setw(f) <<endl;
 }
 }
 return 0;
 }
C++11 capable compiler is I think going to complain about line# 7, it wont like "function" as function name

Compilers should also complain about passing int to pow look at pow here http://www.cplusplus.com/reference/clibrary/cmath/pow/ or/and assigning output of pow to an int

Your calculation is correct. Apart from these what is your specific question/problem?
Don't use pow to square a number, it's like using a sledgehammer to swat a fly.

1
2
pow(x,2)  // bad
(x*x)  // good 
Topic archived. No new replies allowed.