【解決方法】不足しているコードを埋める


以下のプログラムに不足しているコードを入力して、標準入力から従業員の性別、年齢、および給与を読み取り、同じものを標準出力に出力します。

C++
#include <stdio.h>
void main() {
    char gender;
    short int age;
    float salary;
    printf("Enter an employee gender (M/F), age, salary : ");
    printf("Employee gender is : \n", );
    printf("Employee age is : \n", );
    printf(Employee salary is : \n", );
}

私が試したこと:

C++
#include <stdio.h>
void main() {
    char gender;
    short int age;
    float salary;
    printf("Enter an employee gender (M/F), age, salary : ");
    scanf("%c, %d, %f", &gender, &age, &salary)
    printf("Employee gender is : %c\n", gender);
    printf("Employee age is : %d\n", age);
    printf(Employee salary is : %f\n", salary);
}

解決策 1

ですから、あなたは自分で問題を解決しようとはせず、何の疑問も持たず、私たちに宿題をやってもらいたいだけです。
宿題の問題は、実生活で解決しなければならない種類の問題の単純化されたバージョンです。 目的 学習していて、 練習中.
私たちはあなたの宿題をしません。

HomeWork は、他の人に仕事を頼むスキルをテストするためのものではありません。あなたに考えさせ、受講したコースの理解度と、それらを適用する際の問題点を教師が確認するのを助けるように設定されています。
あなたの失敗は、教師があなたの弱点を見つけ、是正措置を講じるのに役立ちます。
あなたの失敗は、何が機能し、何が機能しないかを学ぶのに役立ちます。これは「試行錯誤」学習と呼ばれます。
ですから、試してみて、レッスンを読み直して、作業を開始してください。 特定の問題で立ち往生している場合は、コードを示して、この正確な問題を説明してください。

解決策 2

コンパイルして、エラーと警告メッセージを調べるだけです。 メッセージは、コンパイラが問題を検出した行番号と列を通知することに注意してください (ここでは例として GCC を使用しています)。

test.c:2:6: warning: return type of ‘main’ is not ‘int’

main() int を返す必要があります。

C++
int main()
{
    /* code goes here*/
    return 0;
}

test.c:7:1: warning: format ‘%d’ expects type ‘int *’, but argument 3 has type ‘short int *’

を使用する必要があります h 接頭辞 short 整数:

//scanf("%c, %d, %f", &gender, &age, &salary)
scanf("%c, %hd, %f", &gender, &age, &salary);

test.c:8:1: error: expected ‘;’ before ‘printf’

前の行の末尾にセミコロンがありません (上記を参照してください。既に追加しています)。

test.c:10:8: error: ‘Employee’ undeclared (first use in this function)
... (more errors on line 10)

その行には二重引用符がありません。

//printf(Employee salary is : %f\n", salary);
printf("Employee salary is : %f\n", salary);

解決策 5

含む ___________________
int main()
{
整数値[q1] [q2]

{
{81,84,88,94}、
{79,83,77,98}
};
int x,y;
printf(“要素は次のとおりです: \n”);
ために(______________________) [q3]

{
ために(________________) [q4]

{
printf(“%d”,_____________); [q5]

}
printf(“\n”);
}

*

解決策 6

include<iostream>
int main()
    {
       int numbers[q1] [q2] 
           { 
            {81,84,88,94},
            {79,83,77,98}
            };
        int x,y; 
        printf("The elements are: \n");
        for(______________________) [q3]
        {
            for(________________)  [q4]
            {
                printf("%d ",_____________); [q5]
            }
            printf("\n");
        }

*

コメント

タイトルとURLをコピーしました