miércoles, 29 de mayo de 2013

PROGRAMACION ESTRUCTURADA

TIPOS DE FUNCIONES

/*funcion sin retorno de valor y sin parametros*/
void suma(void);
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()

{
      system("cls");
      suma();
      getch();
     
     
      }
     
void suma (void)
{
     int a,b,s;
     printf("Dame un valor->");
     scanf("%d",&a);  
     printf("Dame otro valor->");
     scanf("%d",&b);
     s=a+b;
     printf("Suma=%d",s);
    
     }


/*funcion con retorno de valor y sin parametros*/
int suma(void);
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()

{
      int sum;
      system("cls");
      sum=suma();
      printf("Suma=%d",sum);
      getch();
     
     
      }
     
int suma(void)
{
     int a,b,s;
     printf("Dame un valor->");
     scanf("%d",&a);  
     printf("Dame otro valor->");
     scanf("%d",&b);
     s=a+b;
     return s;
    
     }


/*funcion sin retorno de valor y con parametros*/
void suma(int x,int y);
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()

{
      int sum;
      int a,b;
     system("cls");
     printf("Dame un valor->");
     scanf("%d",&a);  
     printf("Dame otro valor->");
     scanf("%d",&b);
      suma(a,b);
      getch();
        }
     
void suma(int x,int y)
{
    
     int s;
     s=x+y;
    printf("Suma=%d",s);
    
     }

/*funcion con retorno de valor y con parametros*/
int suma(int x,int y);
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()

{
      int sum;
      int a,b;
     system("cls");
     printf("Dame un valor->");
     scanf("%d",&a);  
     printf("Dame otro valor->");
     scanf("%d",&b);
     sum=suma(a,b);
     printf("Suma=%d",sum);
      getch();
        }
     
int suma(int x,int y)
{
    
     int s;
     s=x+y;
     return s;   
    
     }

No hay comentarios:

Publicar un comentario