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

11th Oct 2017, 8:27 AM
R Retubado
R Retubado - avatar
3 Respuestas
+ 8
float n; std::cin >> n; for (; n > 0; n -= 0.5) std::cout << n << " ";
11th Oct 2017, 9:02 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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; }
11th Oct 2017, 8:35 AM
Kartikey Sahu
Kartikey Sahu - avatar
0
The answer is not bad but please indicate the flowchart always
4th May 2021, 9:43 AM
Timothy Fallah
Timothy Fallah - avatar