delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/23/22:35:12

From: "Jason Yip" <manman AT netteens DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Please help me to find out the problem.
Date: Tue, 23 Nov 1999 23:02:09 +0800
Organization: netteens.net (Hongkong Telecom IMS)
Lines: 27
Message-ID: <81eabb$n6o$1@imsp026.netvigator.com>
NNTP-Posting-Host: olkc10019.netvigator.com
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

The output of this program is always incorrect. Can anyone tells me why and
correct it?? Thanks a lot!!
What's more, I would like to make the prog to reject -ve input and shows a
msg, then input again. How can I do?
(Can I use for loop only?)

#include <stdio.h>
main ()
{
int i, ppl; float rate, hr, total, pay;
 printf("Please input how many employees have overtime works: ");
 scanf("%d",&ppl);
 for(i=1;i<=ppl;i++){
 {
 printf("Please input the overtime hour of the no %d employee: ", i);
 scanf("%f",&hr);
 printf("Please input the overtime hourly rate of the no %d employee: ", i);
 scanf("%f",&rate);
 pay=hr*rate;
 }
 total+=pay;
 }
 printf("The total overtime pay is %.2f",total);
 return 0;
}


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019