[2-1]

#include<stdio.h>

void main(void)

{

 float a, b, S;

 

 printf("Ener a b: ");

 scanf("%f %f",&a,&b);

 

 S=a*b*0.5;

 

 printf("a=%5.1f b=%5.1f\n",a,b);

 printf("menseki=%6.1f\n",S);

}

 

[2-2]

#include<stdio.h>

void main(void)

{

 float h,w,ideal;

 char c;   /* 別解では不必要 */

 

 printf("Enter your height[cm] and weight[kg] (HxxWxx): ");

 scanf("%c%f%c%f",&c,&h,&c,&w);  /* 別解:scanf("H%fW%f",&h,&w); */

 

 ideal=(h-100.0)*0.9;

 

 printf("Height=%5.1f(cm)\n",h);

 printf("Weight=%5.1f(kg)\n",w);

 printf("Riso=%6.2f(kg)\n",ideal);

 printf("Weight-Riso=%5.2f(kg)\n",w-ideal);

}