Skip to content

Instantly share code, notes, and snippets.

@FlowingSPDG
Last active August 18, 2020 05:19
Show Gist options
  • Select an option

  • Save FlowingSPDG/3a743c196924d07c70db49fabbde584e to your computer and use it in GitHub Desktop.

Select an option

Save FlowingSPDG/3a743c196924d07c70db49fabbde584e to your computer and use it in GitHub Desktop.
正の実数の和を小数点一桁まで出力するプログラム(C)
#include "stdio.h"
int main(void){
float a = 0.00;
float b = 0.00;
printf("Input varialbe A and B : ");
if ( scanf("%f,%f",&a,&b) != 2 ) {
printf("Failed to scan...\n");
return -1;
}
// printf("input A : %f \n",a);
// printf("input B : %f \n",b);
// printf("OUTPUT : %.1f \n",a+b);
printf("%.1f \n",a+b);
// 切り上げ、切り捨てや四捨五入などは指定されなかったので考えていない
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment