私はちょうどCを使用して簡単な電卓を作成しました。 今私のコードでは、私は操作を1つずつ計算することができます。 したがって、私の計算をやり直すのにどんなコードやループを使うべきですか、あるいは私のプログラムをビルドして再度実行することなく別のコードやループを実行する必要があります。非常に基本的なC関数
`
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
float first_value;
float second_value;
char Operation;
printf("Welcome to Shoeb's first calculator :)\nChoose your operation (a for Addition/s for Subtraction/m for Multiplication/d for Division) \nPress small o when done calculation ^_^\n");
scanf("%s", &Operation);
if (Operation == 'a') {
printf("Type in your first number below.\n");
scanf("%f", &first_value);
printf("Type in you second value below.\n");
scanf("%f", &second_value);
printf("The result is %f", first_value+second_value);
}
if (Operation == 's') {
printf("Type in your first number below.\n");
scanf("%f", &first_value);
printf("Type in you second value below.\n");
scanf("%f", &second_value);
printf("The result is %f", first_value-second_value);
}
if (Operation == 'm') {
printf("Type in your first number below.\n");
scanf("%f", &first_value);
printf("Type in you second value below.\n");
scanf("%f", &second_value);
printf("The result is %f", first_value*second_value);
}
if (Operation == 'd') {
printf("Type in your first number below.\n");
scanf("%f", &first_value);
printf("Type in you second value below.\n");
scanf("%f", &second_value);
printf("The result is %f\n", first_value/second_value);
}
return 0;
}
`
'のscanf( "%sの"、&オペレーション)'と 'do..while' –