florin sign (ƒ) usage?

Following along in my book and they had me adjust a functioning program I wrote by using this florin sign (ƒ) however, copying straight from the book I am unable to compile and I don't understand the error message either. "Chap 3\Testscores3.cpp:17: error: stray '\131' in program"

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
// Test Average
#include<iostream.h>
#include<conio.h>

int main()
    {
    int testScore[30];
    int test = 0, a;
    double total = 0;
    double average;
    cout<<"Enter first test score, or 999 to quit ";
    cin>>testScore[test];
    while(testScore[test] !=999 && test < 30)
         {
            total += testScore[test];
            ++test;
            if( test<ƒ30)
            {
            cout<<"Enter next test score or 999 to quit ";
            cin>>testScore[test];
            }
            }
    cout<<"The entered test scores are: ";
    for(a = 0; a < test; ++a)
          cout<<testScore[a]<<"  ";
    average = total/test;
    cout<<"The average test score is "<<average<<endl;
    getch();
}
    


Thank you in advance. Also, I am using bloodshed.
And what happens if you try without the florin symbol?
Presumably the aim of this exercise is to see what happens when code which works is modified so that it doesn't work, and to become familiar with the error messages from the compiler.

On an slightly unrelated topic, the Bloodshed software is obsolete, it was last updated over 8 years ago, in 2005. I would highly recommend that you upgrade to the latest version: http://orwelldevcpp.blogspot.co.uk/
The material is trying to illustrate how to regulate arrays and avoid input beyond the arrays declaration when the final function will ignore this input. I figured it would work fine without the symbol but I feel like I am cheating myself if I don't understand it's usage here.

Thanks for the heads up on the Bloodshed being out of date, I'll take a peek at your link.
The error says that on line 17, you have a funny character (character code '\131'). If I look at your code, I see that on line 17, you have a funny character. This will not compile for a few reasons:

1. The florin operator is not supported by default
2. You haven't declared ƒ30 as a function or as a variable.
3. It's not a standard UTF-8 character and may not be supported by your compiler.

It'd be a better idea to do this:
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
31
32
33
34
// Test Average
#include<iostream.h>
#include<conio.h>

int florin(int x)
{
    //  Fill out the implementation of this function here and return the result.
}

int main()
    {
    int testScore[30];
    int test = 0, a;
    double total = 0;
    double average;
    cout<<"Enter first test score, or 999 to quit ";
    cin>>testScore[test];
    while(testScore[test] !=999 && test < 30)
         {
            total += testScore[test];
            ++test;
            if( test<florin(30)) // changed ƒ30 to florin(30)... this is how a function is written in most programming languages
            {
            cout<<"Enter next test score or 999 to quit ";
            cin>>testScore[test];
            }
            }
    cout<<"The entered test scores are: ";
    for(a = 0; a < test; ++a)
          cout<<testScore[a]<<"  ";
    average = total/test;
    cout<<"The average test score is "<<average<<endl;
    getch();
}
Last edited on
I figured it would work fine without the symbol but I feel like I am cheating myself if I don't understand it's usage here.


You wouldn't be cheating yourself. There is no valid reason to have it there, as your compiler has attested.
@Stewbond
I was thinking just this:

1
2
3
if( test < 30) {

}


It is about limiting the input to the array, as kilrothy said.
Topic archived. No new replies allowed.