私のプログラムは複数の入力を受け入れることができます(scanf
&ループを使用)&計算後にそれぞれ結果を出力しますか?複数の入力を持つscanfとループ-c
私のプログラムは6つの入力を受け入れますが、1つの出力しか表示しません。次の出力を得たいと思います:。
#include <stdio.h>
#include <string.h>
main() {
// Declaring variables
char name[25];
int hours, rate, gross, bonus, counter;
printf(" A program to determine the gross pay for six Employees\n Please Enter the Name, No. of hours worked and hourly rate respectively\n");
for (counter = 1; counter <= 6; counter++) {
scanf("%s %d %d", &name, &hours, &rate);
gross = hours * rate; // determining the gross pay
printf("%s %d %d %d\n", name, hours, rate, gross);
}
}
'のscanf( "%sの%D%D"、&名、および時間、&rate);'へ
scanf("%s %d %d",&name,&hours,&rate);
(%s%d%d)、&name [0]、&hours、&rate); ' – LPs
' main() ' - >' scanf( "%s%d%d"、名前、&時間、&rate); 'または' - > 'int main(void)' – LPs
あなたはその情報を保持する 'struct'を定義し、次にarその 'struct 'のレイは、多くの従業員の情報を保持することができます。 –