Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<stdlib.h>
- void nacitaj(double *a,double *b){
- scanf("%lf %lf\n",a,b);
- }
- double obsah(double a, double b){
- return ((a) * (b));
- }
- double obvod(double a, double b){
- return (2* ((a) + (b)));
- }
- double (*p_f)(double a, double b);
- int main (void){
- char c;
- double *a,*b;
- a=(double *) malloc(sizeof(double));
- b=(double *) malloc(sizeof(double));
- nacitaj(a,b);
- if ((c=getchar())=='s'){
- p_f=obsah;
- printf("%.3lf\n",p_f(*a,*b));
- }
- else if (c =='o'){
- p_f=obvod;
- printf("%.3lf\n",p_f(*a,*b));
- }
- getchar();
- getchar();
- return 0;
- }
Add Comment
Please, Sign In to add comment