Przykład nr 11

by Maciej Lasota published 2018/12/13 16:34:17 GMT+1, last modified 2018-12-13T16:34:17+01:00
#include <stdio.h>
#include <stdlib.h>


float suma(float a, float b)
{
    return(a+b);
}

float roznica(float a, float b)
{
    return(a-b);
}

float iloczyn(float a, float b)
{
    return(a*b);
}

float iloraz(float a, float b)
{
    return(a/b);
}

int main(int argc, char *argv[])
{
    float x,y;
    
    if(argc != 3)
    {
	printf("Blad!, wywolanie programu: %s [liczba1] [liczba2]\n",argv[0]);
	exit(0);
    }
    
    x = atof(argv[1]);
    y = atof(argv[2]);
    
    printf("SUMA liczb: %.2f + %.2f = %.4f\n",x,y,suma(x,y));
    printf("ROZNICA liczb: %.2f - %.2f = %.4f\n",x,y,roznica(x,y));
    printf("ILOCZYN liczb: %.2f * %.2f = %.4f\n",x,y,iloczyn(x,y));
    printf("ILORAZ liczb: %.2f / %.2f = %.4f\n",x,y,iloraz(x,y));
    	
    return (0);    
}