[Plain]
* Start the comments in the program header (to avoid any problems encountered in submitting a blog post, it will be used to indicate that the comments have been deleted by the slash)
* Copyright and version Declaration of the program
* All rights reserved.
* File name: txt. c
* Author: liuyongshui
* Question: Constantly input real numbers from the keyboard, and accumulate the input side until the sum of these numbers exceeds 1000.
* Problem source:
* Completion date: January 1, April 22, 2013
* Version No.: V1.0
*/
# Include <stdio. h>
Void star (void); // print the asterisk
Int main ()
{
Int I;
Float num;
Float sum = 0.0;
Star (); // print the asterisk
Printf ("enter a real number :");
Scanf ("% f", & num );
For (I = 0; sum <= 1000; I ++)
{
Sum + = num;
If (sum <= 1000)
{
Printf ("\ n because sum = % 0.2f is smaller than 1000, please input another real number:", sum );
Scanf ("% f", & num );
}
Else
{
Printf ("\ n Haha sum = % 0.2f, later than 1000, thank you for your cooperation! \ NGOOD BYE! \ N ", sum );
}
}
Star (); // print the asterisk
Return 0;
}
// Star Function
Void star (void)
{
Int I;
For (I = 0; I <60; I ++)
{
Printf ("*");
}
Printf ("\ n ");
}
/* Start the comments in the program header (to avoid any problems encountered during the submission of blog posts, the slash used to indicate that the comments have been deleted)
* Copyright and version Declaration of the program
* All rights reserved.
* File name: txt. c
* Author: liuyongshui
* Question: Constantly input real numbers from the keyboard, and accumulate the input side until the sum of these numbers exceeds 1000.
* Problem source:
* Completion date: January 1, April 22, 2013
* Version No.: V1.0
*/
# Include <stdio. h>
Void star (void); // print the asterisk
Int main ()
{
Int I;
Float num;
Float sum = 0.0;
Star (); // print the asterisk
Printf ("enter a real number :");
Scanf ("% f", & num );
For (I = 0; sum <= 1000; I ++)
{
Sum + = num;
If (sum <= 1000)
{
Printf ("\ n because sum = % 0.2f is smaller than 1000, please input another real number:", sum );
Scanf ("% f", & num );
}
Else
{
Printf ("\ n Haha sum = % 0.2f, later than 1000, thank you for your cooperation! \ NGOOD BYE! \ N ", sum );
}
}
Star (); // print the asterisk
Return 0;
}
// Star Function
Void star (void)
{
Int I;
For (I = 0; I <60; I ++)
{
Printf ("*");
}
Printf ("\ n ");
} Example: