• Language

    C

  • Description

    It asks the name, the gender, and the salary to an user.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    int gender;
    float salary, your_salary;
    char your_name[63];
    printf ("Enter the your name: ");
    scanf ("%[^\r\n]", your_name);
    (void) getchar ();
    printf ("Enter the value of your salary: ");
    scanf ("%f", &your_salary);
    (void) getchar ();
    printf ("Select the value of gender.\n");
    printf ("\t1.- Female\n");
    printf ("\t2.- Male\n");
    printf ("\t: ");
    do {
        scanf ("%d", &gender);
        (void) getchar ();
        if (gender<1||gender>2)
            printf ("Wrong value. Please, enter it again.: ");
    } while (gender<1||gender>2);
    salary=your_salary;
    if(gender==1)
        printf ("Female\n");
    else
        printf ("Male\n");
    printf ("Your name: %s\n", your_name);
    printf ("Value of salary: %g\n", salary);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}