This is program that enables the user to input two values and it calculates the average, the sum and the ratio of the two numbers.
I used the printf and the puts function.
I also learnt how to do some simple calculations using C language.
The code:
#include <stdio.h>
int main(void)
{
double a,b;
puts("2数の平均値\n");
printf("数1:"); scanf("%lf", &a); /*%fは小数表示ってこと*/
printf("数2:"); scanf("%lf", &b); /*ただしscanf関数の場合は%lfとなる!!*/
printf("合計値は%f。\n", a+b);
printf("平均値は%f。\n", (a+b)/2);
printf("aはbの%f%%\n", a*100/b);
return(0);
}
I used the printf and the puts function.
I also learnt how to do some simple calculations using C language.
The code:
#include <stdio.h>
int main(void)
{
double a,b;
puts("2数の平均値\n");
printf("数1:"); scanf("%lf", &a); /*%fは小数表示ってこと*/
printf("数2:"); scanf("%lf", &b); /*ただしscanf関数の場合は%lfとなる!!*/
printf("合計値は%f。\n", a+b);
printf("平均値は%f。\n", (a+b)/2);
printf("aはbの%f%%\n", a*100/b);
return(0);
}

0 件のコメント:
コメントを投稿