How to eliminate the title in do-while loop for the first loop?
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// Function main begins program execution
int main(void)
{
char date[11], name[50], *line, performance[10], rate[3], yesno;
int a;
// Title
printf("Payslip system\n\n");
// Prompt and read the date
printf("Date: ");
fgets(date, sizeof(date), stdin);
fflush(stdin);
/*Prompt user whether continue or stop creating Payslip */
// Start do-while loop
do
{
// Title
printf("Payslip system\n\n");
// Prompt and read the user's name
printf("Name: ");
fgets(name, sizeof(name), stdin);
// Remove newline
line = strchr(name,'\n');
*line = '\0';
// Prompt and read the user's sales amount of the day
printf("Sales Amount: ");
scanf("%d", &a);
if (a >= 2000)
{
strcpy (performance,"Excellent");
strcpy (rate,"3%");
}
else if (a >= 1000)
{
strcpy (performance,"Good");
strcpy (rate,"2%");
}
else
{
strcpy (performance,"Fair");
strcpy (rate,"1%");
}
// Display payslip
printf("%s\n", name);
printf("%s\n", date);
printf("%s\n", performance);
printf("%s\n", rate);
// Prompt and read the user whether continue or end
printf("Continue (Y/N)? ");
scanf(" %c",&yesno);
fflush(stdin);
printf("\n");
} while (yesno == 'Y' || yesno == 'y');
// End do-while loop
// Pause the system and prompt the user to terminate the program
system ("pause");
}