elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  FUNCIONES Y PROCEDIMIENTO
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 Ir Abajo Respuesta Imprimir
Autor Tema: FUNCIONES Y PROCEDIMIENTO  (Leído 4,434 veces)
programador10

Desconectado Desconectado

Mensajes: 15


Ver Perfil
FUNCIONES Y PROCEDIMIENTO
« en: 28 Abril 2011, 19:39 pm »


BUENAS TARDE








#include <cstdlib>
#include <iostream>

using namespace std;

void leer(int,int,int);
void operacion(int ,int ,int );



int main(int argc, char *argv[])
{   
    int edad1,nac1,act1;
   
   leer(edad1,nac1,act1);
   operacion(edad1,nac1,act1);
   
                     
    system("PAUSE");
    return EXIT_SUCCESS;
}

void leer(int &edad,int &nac,int &act)
{   
             
     cout<<"ingrese Edad"<<endl;
     cin>>edad;
     cout<<"ingrese Año de Nacimiento"<<endl;
     cin>>nac;
     cout<<"ingrese Año Actual"<<endl;
     cin>>act;     
       
}

void operacion(int &edad,int &nac,int &act)
{   
     cout<<"Bueno el tendras "<<(act-nac+edad)<<endl;         
     cin>>edad;
     cout<<edad;
     
   }


En línea

El_Java

Desconectado Desconectado

Mensajes: 144



Ver Perfil WWW
Re: FUNCIONES Y PROCEDIMIENTO
« Respuesta #1 en: 28 Abril 2011, 19:42 pm »

Y que nos quieres decir con esto?

Pd. para codigo usa etiquetas GeSHI


En línea

programador10

Desconectado Desconectado

Mensajes: 15


Ver Perfil
Re: FUNCIONES Y PROCEDIMIENTO
« Respuesta #2 en: 28 Abril 2011, 19:45 pm »

hola  gracias ... pero DONDE   ME INFORMO PARA PODER  postear de la mejor forma "EN ESTE FORO" gracias.
En línea

leogtz
. . .. ... ..... ........ ............. .....................
Colaborador
***
Desconectado Desconectado

Mensajes: 3.069


/^$/


Ver Perfil WWW
Re: FUNCIONES Y PROCEDIMIENTO
« Respuesta #3 en: 28 Abril 2011, 19:50 pm »

Solo escribe correctamente, y si quieres poner un código, seleccionalo y elige GeShi en el editor de mensajes, ahí seleccionas el lenguaje que quieras y ya.
En línea

Código
  1. (( 1 / 0 )) &> /dev/null || {
  2. echo -e "stderrrrrrrrrrrrrrrrrrr";
  3. }
  4.  
http://leonardogtzr.wordpress.com/
leogutierrezramirez@gmail.com
programador10

Desconectado Desconectado

Mensajes: 15


Ver Perfil
Re: FUNCIONES Y PROCEDIMIENTO
« Respuesta #4 en: 28 Abril 2011, 19:51 pm »


Buenas TArdes El Siguiente codigo no me compila
Código
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. void leer(int,int,int);
  7. void operacion(int ,int ,int );
  8.  
  9.  
  10.  
  11. int main(int argc, char *argv[])
  12. {  
  13.    int edad1,nac1,act1;
  14.  
  15.   leer(edad1,nac1,act1);
  16.   operacion(edad1,nac1,act1);
  17.  
  18.  
  19.    system("PAUSE");
  20.    return EXIT_SUCCESS;
  21. }

y no comprendo por que no compila.
en la parte inferior me sale las siguistes obsevaciones.
  

  [Linker error] undefined reference to `leer(int, int, int)'
  [Linker error] undefined reference to `operacion(int, int, int)'
  ld returned 1 exit status



espero  SU AYUDA .!GRACIAS!



En línea

programador10

Desconectado Desconectado

Mensajes: 15


Ver Perfil
Re: FUNCIONES Y PROCEDIMIENTO
« Respuesta #5 en: 28 Abril 2011, 19:53 pm »

Código
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. void leer(int,int,int);
  7. void operacion(int ,int ,int );
  8.  
  9.  
  10.  
  11. int main(int argc, char *argv[])
  12. {  
  13.    int edad1,nac1,act1;
  14.  
  15.   leer(edad1,nac1,act1);
  16.   operacion(edad1,nac1,act1);
  17.  
  18.  
  19.    system("PAUSE");
  20.    return EXIT_SUCCESS;
  21. }
  22.  
  23. void leer(int &edad,int &nac,int &act)
  24. {    
  25.  
  26.     cout<<"ingrese Edad"<<endl;
  27.     cin>>edad;
  28.     cout<<"ingrese Año de Nacimiento"<<endl;
  29.     cin>>nac;
  30.     cout<<"ingrese Año Actual"<<endl;
  31.     cin>>act;    
  32.  
  33. }
  34.  
  35. void operacion(int &edad,int &nac,int &act)
  36. {    
  37.     cout<<"Bueno el tendras "<<(act-nac+edad)<<endl;          
  38.     cin>>edad;
  39.     cout<<edad;
  40.  
  41.   }
  42.  
En línea

leogtz
. . .. ... ..... ........ ............. .....................
Colaborador
***
Desconectado Desconectado

Mensajes: 3.069


/^$/


Ver Perfil WWW
Re: FUNCIONES Y PROCEDIMIENTO
« Respuesta #6 en: 28 Abril 2011, 19:59 pm »

Fijate que en el prototipo de la función leer(), no coinciden los parámetros con la definición después.

Debería ser así:

Código
  1. void leer(int&,int&,int&);
  2. void operacion(int &,int &,int &);
  3.  

Código
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. void leer(int&,int&,int&);
  7. void operacion(int &,int &,int &);
  8.  
  9. int main(int argc, char *argv[])
  10. {
  11.    int edad1,nac1,act1;
  12.  
  13.   leer(edad1,nac1,act1);
  14.   operacion(edad1,nac1,act1);
  15.  
  16.    system("pause");
  17.    return EXIT_SUCCESS;
  18. }
  19.  
  20. void leer(int &edad,int &nac,int &act)
  21. {
  22.  
  23.     cout<<"ingrese Edad"<<endl;
  24.     cin>>edad;
  25.     cout<<"ingrese Año de Nacimiento"<<endl;
  26.     cin>>nac;
  27.     cout<<"ingrese Año Actual"<<endl;
  28.     cin>>act;
  29.  
  30. }
  31.  
  32. void operacion(int &edad,int &nac,int &act)
  33. {
  34.     cout<<"Bueno el tendras "<<(act-nac+edad)<<endl;
  35.     cin>>edad;
  36.     cout<<edad;
  37. }
  38.  
En línea

Código
  1. (( 1 / 0 )) &> /dev/null || {
  2. echo -e "stderrrrrrrrrrrrrrrrrrr";
  3. }
  4.  
http://leonardogtzr.wordpress.com/
leogutierrezramirez@gmail.com
programador10

Desconectado Desconectado

Mensajes: 15


Ver Perfil
Re: FUNCIONES Y PROCEDIMIENTO
« Respuesta #7 en: 28 Abril 2011, 20:05 pm »

disculpa podrias especificar mejor en donde esta mi error. GRACIAS ;)    :huh:
En línea

leogtz
. . .. ... ..... ........ ............. .....................
Colaborador
***
Desconectado Desconectado

Mensajes: 3.069


/^$/


Ver Perfil WWW
Re: FUNCIONES Y PROCEDIMIENTO
« Respuesta #8 en: 28 Abril 2011, 20:09 pm »

Tu lo tenías así:

Código
  1. void leer(int,int,int);
  2. void operacion(int ,int ,int );

Y debe ser así:

Código
  1. void leer(int&,int&,int&);
  2. void operacion(int &,int &,int &);

C++ tiene sobrecarga de funciones, por lo que el procedimiento:

Código
  1. void leer(int&,int&,int&);
es distinto a:
Código
  1. void leer(int,int,int);

Saludos.
En línea

Código
  1. (( 1 / 0 )) &> /dev/null || {
  2. echo -e "stderrrrrrrrrrrrrrrrrrr";
  3. }
  4.  
http://leonardogtzr.wordpress.com/
leogutierrezramirez@gmail.com
programador10

Desconectado Desconectado

Mensajes: 15


Ver Perfil
Re: FUNCIONES Y PROCEDIMIENTO
« Respuesta #9 en: 28 Abril 2011, 20:16 pm »

TENIAS MUCHA RAZON. GRACIAS , UN ABRAZO A LA DISTANCIO. QUE CHEVERE COMPILO
En línea

Páginas: [1] 2 Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
llamar a un procedimiento de un modulo
Programación Visual Basic
choquito 4 1,895 Último mensaje 25 Marzo 2007, 00:09 am
por Sancho.Mazorka
ayuda con procedimiento
Programación Visual Basic
4D1cTo 8 3,120 Último mensaje 19 Febrero 2008, 03:54 am
por Chefito
llamar Procedimiento Almacenado
Programación Visual Basic
juanjoxx 0 1,384 Último mensaje 9 Septiembre 2008, 05:23 am
por juanjoxx
procedimiento apagado switch 6500
Redes
arvegas 4 11,003 Último mensaje 28 Enero 2012, 17:38 pm
por ThonyMaster
Ayuda con procedimiento
.NET (C#, VB.NET, ASP)
SγиtαxEяяoя 3 2,196 Último mensaje 10 Julio 2013, 21:10 pm
por SγиtαxEяяoя
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines