# 's' can not be used as a function

Page 1 of 1

## 2 Replies - 2049 Views - Last Post: 16 February 2010 - 09:51 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=156463&amp;s=447679c4820cec8dd33a4dee7c34e014&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 vonnie15

Reputation: 0
• Posts: 7
• Joined: 16-February 10

# 's' can not be used as a function

Posted 16 February 2010 - 09:31 PM

I have an error that states
's' can not be used as a function

here is my code

```// Isak Ivanic
// 2/16/10
// CSC 150, 2:00 pm
// Program 3 Part 1
// This program calculates the total area as well as perimeter of a triangle
#include <iostream>
#include <iomanip>             // For setpercision
#include <cmath>               // For the sqrt function
using namespace std;

void welcome ();               // Welcome function

int main ()

{
welcome();                      // Function call
double lengthA,                 // To hold the length of side A
lengthB,                  // To hold the length of side B
lengthC,                  // To hold the length of side C
A,                        // To hold the area formula
s;                        // To hold the perimeter formula

// Calculate the perimemter and area of the triangle
cout << "The length of side A is: ";
cin >> lengthA;
cout << "The length of side B is: ";
cin >> lengthB;
cout << "The length of side C is: ";
cin >> lengthC;
s=(lengthA + lengthB + lengthC)/2;

//Display the perimeter
cout << "The perimeter of the triangle is:" << s;

//Calculate the area of the triangle
A=sqrt(s(s-lengthA)(s-lengthB)(s-lengthC));

//Display the area of the triangle
cout << setprecision(1) << "The area of the triangle is: " << A << endl;

system ("Pause");

return 0;
}

// Function definition
void welcome ()
{
cout << "*************************************\n";
cout << "* Welcom to the best program ever! *\n";
cout << "**************************************\n";
}

```

The Error takes place here

```  //Calculate the area of the triangle
A=sqrt(s(s-lengthA)(s-lengthB)(s-lengthC));

```

Is This A Good Question/Topic? 0

## Replies To: 's' can not be used as a function

### #2 anonymouscodder

Reputation: 126
• Posts: 710
• Joined: 01-January 10

## Re: 's' can not be used as a function

Posted 16 February 2010 - 09:41 PM

```A=sqrt(s(s-lengthA)(s-lengthB)(s-lengthC));
```
In C/C++ there is no implicit multiplication as in math..

So if your idea was to perform a multiplication, the correct would be:
```A=sqrt(s*(s-lengthA)*(s-lengthB)*(s-lengthC));
```

### #3 vonnie15

Reputation: 0
• Posts: 7
• Joined: 16-February 10

## Re: 's' can not be used as a function

Posted 16 February 2010 - 09:51 PM

anonymouscodder, on 16 February 2010 - 08:41 PM, said:

```A=sqrt(s(s-lengthA)(s-lengthB)(s-lengthC));
```
In C/C++ there is no implicit multiplication as in math..

So if your idea was to perform a multiplication, the correct would be:
```A=sqrt(s*(s-lengthA)*(s-lengthB)*(s-lengthC));
```

Thank you!