0
Input a value for variable n, repeatedly print the value of n, decreasing it by 0.5 each time, as long as n remains positive
using c++. this is for our subject. i hope some can help me
3 Antworten
+ 8
float n; std::cin >> n;
for (; n > 0; n -= 0.5)
std::cout << n << " ";
+ 3
#include <iostream>
using namespace std;
int main() {
float n;
cout<<"Enter the number ";
cin>>n;
cout<<n<<":\n";
while(n >= 0){
cout<<n<<" ";
n -= 0.5;
}
return 0;
}
0
The answer is not bad but please indicate the flowchart always