about C++
来源:百度知道 编辑:UC知道 时间:2024/09/22 03:47:38
write an simple programme about C++
5. Draw a flowchart based on the following psuedocode:
Begin
Initialize Count to 0
DoWhile Count is less than 10
Input Rate and Time
If Rate is greater than or equal to 60
Distance is equal to Rate * Time
Output the Rate, Time, and Distance
EndIf
Add 1 to Count
End Do
End
6. Based on the flowchart in the previous question, the program design is not good at all. For instance, if the user inputs negative values of Time, the program will display negative distance, which is not logical at all. Try to improve the design so that:
• the program will display appropriate error messages on screen when the user inputs wrong values of Rate and/or Time.
• the program will ask the user to continue calculating distance or not after each output is displayed on screen instead of calculating distance for exactly 10 times.
Write a C program (with comments
5. Draw a flowchart based on the following psuedocode:
Begin
Initialize Count to 0
DoWhile Count is less than 10
Input Rate and Time
If Rate is greater than or equal to 60
Distance is equal to Rate * Time
Output the Rate, Time, and Distance
EndIf
Add 1 to Count
End Do
End
6. Based on the flowchart in the previous question, the program design is not good at all. For instance, if the user inputs negative values of Time, the program will display negative distance, which is not logical at all. Try to improve the design so that:
• the program will display appropriate error messages on screen when the user inputs wrong values of Rate and/or Time.
• the program will ask the user to continue calculating distance or not after each output is displayed on screen instead of calculating distance for exactly 10 times.
Write a C program (with comments
void dis5()
{
int count=0;//init count;
float rate, time; //define speed, time (s)
while(count<=10)
{
printf("Input the rate and time\n");
scanf("%f%f",&rate,&time);
printf("Rate:%f,time:%f,distance:%f",rate,time,rate*time)
}
}
void dis6()
{
int count=0;//init count;
float rate, time; //define speed, time (s)
while(count<=10)
{
printf("Input the rate and time\n");
scanf("%f%f",&rate,&time);
if(rate<=0||time<0)
printf("Wrong data");
break;
printf("Rate:%f,time:%f",rate,time)
printf("Do you wanna to print the distance?")
char ch=getchar();
if(ch=='y'||ch=='Y')
printf(",%f",rate*time)
}
}
All rights reserved.(c)版权所有,严禁拷贝!
about c语言该咋写
单项选择 May asked me _I thought about each thing a.how b.what c.which
I am not familiar ______ this machine.A.to B.toward C.with D.about
A. came across B. came about C. came after D. came at
She is going to leave home ____seven fifteen. ( A. about B. before C. on)
res://C:\WINDOWS\system32\Search.dll/ABOUT.HTM
We ____ so much about you every day. A. say B. tell C. speak D.talk
Do you know the answer ______the question A.about B.of C.toD. on
My mother likes visiting_____others. A. for B. with C. about D. to
What did Mr Chen ( ) about the centre of town? A.talk B.say C.speak