• (2 Pages)
• 1
• 2

## 17 Replies - 1488 Views - Last Post: 19 October 2009 - 09:54 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=133093&amp;s=d439479cde9982f10f3130ea309dbce9&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Photographer

Reputation: 0
• Posts: 17
• Joined: 19-October 09

Posted 19 October 2009 - 07:41 PM

Hello! Everyone I Have This Code I'm Working on but I'm Getting a few Errors if some one could shed some light
Basically i took "seeP+" 's code from this Thread DreamInCode and tried to make it with "5 functions" = 1 main; 3xInputs & 1 Average Calculator" heres the Code I APOLOGIZE FOR THE SPANISH I JUST TRANSLATED THE OP'S COMMENTS TO SPANISH PLEASE NO FLAMING

```// funciones promedio

#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>
#include <conio.h>
#include <iostream>

using namespace std;

//funciones
double promedio (int, int, int);
int nota1 (int);
int nota2 (int);
int nota3 (int);

//cin de notas
int Nota1(int nota1)

{
nota1=0;
cout << "\nEntre Primera Nota: \a";
cin >> nota1;
return nota1;
}

int Nota2(int nota2)
{
nota2=0;
cout << "\nEntre Primera Nota: \a";
cin >> nota2;
return nota2;
}

int Nota3(int nota3)
{
nota3=0;
cout << "\nEntre Primera Nota: \a";
cin >> nota3;
return nota3;

}

//funcion promedio
double promedio (int num1, int num2, int num3)
{
double average = 0.0;
average = double(num1 + num2 + num3) / 3.0;

return average;

} //end de la funcion promedio

int main()
{

//llamado a funcion para calcular promedio
average //= promedio (nota1, nota2, nota3);
cout << "\nEl Promedio de las 3 Notas es: \a" << average << endl;
cout << "\nPresione Cualquier tecla Para Salir...";

getch();

return 0;
} //end de la funcion main

```

Here is the "output":

1>------ Build started: Project: 06, Configuration: Debug Win32 ------
1>Compiling...
1>06.cpp
1>c:\users\*****\desktop\vs projects\06\06\06.cpp(72) : error C2065: 'average' : undeclared identifier
1>c:\users\*****\desktop\vs projects\06\06\06.cpp(72) : error C2146: syntax error : missing ';' before identifier 'cout'
1>c:\users\*****\desktop\vs projects\06\06\06.cpp(72) : error C2065: 'average' : undeclared identifier
1>Build log was saved at "file://c:\Users\*****\Desktop\VS Projects\06\06\Debug\BuildLog.htm"
1>06 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This post has been edited by Photographer: 19 October 2009 - 07:47 PM

Is This A Good Question/Topic? 0

## Replies To: 3 Grade Average

### #2 jwwicks

Reputation: 24
• Posts: 162
• Joined: 31-July 08

Posted 19 October 2009 - 07:50 PM

Hello,

Photographer, on 19 Oct, 2009 - 06:41 PM, said:

```// funciones promedio

int main()
{

//llamado a funcion para calcular promedio
average //= promedio (nota1, nota2, nota3);
cout << "\nEl Promedio de las 3 Notas es: \a" << average << endl;
cout << "\nPresione Cualquier tecla Para Salir...";
getch();
return 0;
} //end de la funcion main

```

```double average = 0.0;

```

Jw

### #3 Tshiknn

Reputation: 4
• Posts: 20
• Joined: 18-October 09

Posted 19 October 2009 - 07:51 PM

If you could tell me what "Notal" means, I could probably help you.

### #4 Photographer

Reputation: 0
• Posts: 17
• Joined: 19-October 09

Posted 19 October 2009 - 07:56 PM

Tshiknn, on 19 Oct, 2009 - 06:51 PM, said:

If you could tell me what "Notal" means, I could probably help you.

Promedio = Average

jwwicks, on 19 Oct, 2009 - 06:50 PM, said:

Hello,

Photographer, on 19 Oct, 2009 - 06:41 PM, said:

```// funciones promedio

int main()
{

//llamado a funcion para calcular promedio
average //= promedio (nota1, nota2, nota3);
cout << "\nEl Promedio de las 3 Notas es: \a" << average << endl;
cout << "\nPresione Cualquier tecla Para Salir...";
getch();
return 0;
} //end de la funcion main

```

```double average = 0.0;

```

Jw

I Did And Only said This

1>c:\users\*****\desktop\vs projects\06\06\06.cpp(71) : error C2664: 'promedio' : cannot convert parameter 1 from 'int (__cdecl *)(int)' to 'int'

Almost There!

This post has been edited by Photographer: 19 October 2009 - 07:53 PM

### #5 brds

Reputation: 76
• Posts: 515
• Joined: 22-October 08

Posted 19 October 2009 - 07:58 PM

Hows about you change average //= promedio(nota1, nota2, nota3); to average /= promedio(nota1(1), nota2(2), nota3(3));.

// starts a comment. nota# is a function that requires that you pass an int.

Of course you realize that average /= promedio(nota1(1), nota2(2), nota3(3)); is functionally the same as average /= promedio(1, 2, 3);?

Also, cut & pasting code you don't understand is not wise.

### #6 Photographer

Reputation: 0
• Posts: 17
• Joined: 19-October 09

Posted 19 October 2009 - 08:05 PM

I DID UNDERSTAND THE CODE Man; i just not getting the mods i want to make to it; I know it's an disgrace to the Original Code; But at least i'm trying....

This post has been edited by Photographer: 19 October 2009 - 08:06 PM

### #7 brds

Reputation: 76
• Posts: 515
• Joined: 22-October 08

Posted 19 October 2009 - 08:18 PM

Oh wait my bad... = not /=, you probably don't want to divide.

My OP wasn't meant to insult. Could you post current code & errors if any?

### #8 Photographer

Reputation: 0
• Posts: 17
• Joined: 19-October 09

Posted 19 October 2009 - 08:27 PM

brds, on 19 Oct, 2009 - 07:18 PM, said:

Oh wait my bad... = not /=, you probably don't want to divide.

My OP wasn't meant to insult. Could you post current code & errors if any?

No Problem Dude Sorry For The CAPS lol
Here's where i am @ the moment: no errors it runs but i only see the couts of the (int main) it only shows:

________________________________
|El Promedio de las 3 Notas es: 2 |
|Presione Cualquier tecla Para Salir... |
| |
|_______________________________|
```// funciones promedio

#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>
#include <conio.h>
#include <iostream>

using namespace std;

//funciones
double promedio (int, int, int);
int nota1 (int);
int nota2 (int);
int nota3 (int);

//cin de notas
int Nota1(int nota1)

{
nota1=0;
cout << "\nEntre Primera Nota: \a";
cin >> nota1;
return nota1;
}

int Nota2(int nota2)
{
nota2=0;
cout << "\nEntre Segunda Nota: \a";
cin >> nota2;
return nota2;
}

int Nota3(int nota3)
{
nota3=0;
cout << "\nEntre Tercera Nota: \a";
cin >> nota3;
return nota3;

}

//funcion promedio
double promedio (int num1, int num2, int num3)
{
double average = 0.0;
average = double(num1 + num2 + num3) / 3.0;

return average;

} //end de la funcion promedio

int main()
{

int Nota1= 0.0;
int Nota2= 0.0;
int Nota3= 0.0;
double average = 0.0;

//llamado a funcion para calcular promedio
average  = promedio(1, 2, 3);
cout << "\nEl Promedio de las 3 Notas es: \a" << average << endl;
cout << "\nPresione Cualquier tecla Para Salir...";

getch();

return 0;
} //end de la funcion main

```

This post has been edited by Photographer: 19 October 2009 - 09:34 PM

### #9 Photographer

Reputation: 0
• Posts: 17
• Joined: 19-October 09

Posted 19 October 2009 - 08:54 PM

I guess i'm only missing the "call of the functions"

### #10 brds

Reputation: 76
• Posts: 515
• Joined: 22-October 08

Posted 19 October 2009 - 08:59 PM

Ok, the functions nota# do not need you to pass values to them.
```/* Prototype */
int Nota1(void);

/* Function */
int Nota1(void) {
int nota1 = 0;
cout << "\nEntre Primera Nota: \a";
cin >> nota1;
return nota1;
}

```

```average = promedio(Nota1(), Nota2(), Nota3());

```

If you want I can nitpick some other stuff

@edit: capitalization.

This post has been edited by brds: 19 October 2009 - 09:00 PM

### #11 Photographer

Reputation: 0
• Posts: 17
• Joined: 19-October 09

Posted 19 October 2009 - 09:01 PM

^As Long as it has the "5 Functions" Go Crazy With It!!!

### #12 brds

Reputation: 76
• Posts: 515
• Joined: 22-October 08

Posted 19 October 2009 - 09:13 PM

You write it, I nitpick. Thats the way it works

### #13 Photographer

Reputation: 0
• Posts: 17
• Joined: 19-October 09

Posted 19 October 2009 - 09:19 PM

You're gonna get a kick out of this one it's running Great!.....Buts it's asking for the third grade first and the first grade for last

It SHOULD say :

"Entre la Primera Nota: "
"Entre la Segunda Nota: "
"Entre la Tercerara Nota: "

And it OUTPUTS:

"Entre la Tercera Nota: "
"Entre la Segunda Nota: "
"Entre la Primera Nota: "

Full "Final Draft?" lol

```//funciones promedio

#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>
#include <conio.h>
#include <iostream>

using namespace std;

//funciones
double promedio (int, int, int);
int Nota1(void);
int Nota2(void);
int Nota3(void);

//cin de notas
int Nota1(void) {
int nota1 = 0;
cout << "\nEntre la Primera Nota: \a";
cin >> nota1;
return nota1;
}

int Nota2(void) {
int nota2 = 0;
cout << "\nEntre la Segunda Nota: \a";
cin >> nota2;
return nota2;
}
int Nota3(void) {
int nota3 = 0;
cout << "\nEntre la Tercera Nota: \a";
cin >> nota3;
return nota3;
}

//funcion promedio
double promedio (int num1, int num2, int num3)
{
double average = 0.0;
average = double(num1 + num2 + num3) / 3.0;

return average;

} //end de la funcion promedio

int main()
{
cout << "Riko N. Gonzalez E-00008144\n\a" << endl;
cout << "\nEste progtama Esta hecho Para Calcula el promedio de tres Notas\n" << endl;

int Nota1(void);
int Nota2(void);
int Nota3(void);
double average = 0.0;

//llamado a funcion para calcular promedio
average = promedio(Nota1(), Nota2(), Nota3());
cout << "\nEl Promedio de las 3 Notas es: \a" << average << endl;
cout << "\nPresione Cualquier tecla Para Salir...";

getch();

return 0;
} //end de la funcion main

```

This post has been edited by Photographer: 19 October 2009 - 09:35 PM

### #14 brds

Reputation: 76
• Posts: 515
• Joined: 22-October 08

Posted 19 October 2009 - 09:37 PM

Silly me.
```average = promedio(Nota3(), Nota2(), Nota1());

```

Nitpicking!!!

The only header you need is iostream, and you only need to include it once.

Prototypes don't go inside of main.

cin.get(); not getch();.

```// Main level
// One tab
// Two tabs

int main(void) {
int a=0;

if(a)
cout << "What?" << endl;

return a;
}

```

### #15 Photographer

Reputation: 0
• Posts: 17
• Joined: 19-October 09

Posted 19 October 2009 - 09:46 PM

brds, on 19 Oct, 2009 - 08:37 PM, said:

Silly me.

Nitpicking!!!

The only header you need is iostream, and you only need to include it once.

Prototypes don't go inside of main.

cin.get(); not getch();.

I Corrected it ; the headers is bad habit(i always copy & paste the libraries just in case ) & Youre Right my indentation SUCKS

Thanks!

This post has been edited by Photographer: 19 October 2009 - 09:47 PM

• (2 Pages)
• 1
• 2

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }