0

hello peeps programming for me is not that easy thats why i ask questions.

How do i read numbers until a negative number is entered in c++

14th Aug 2020, 5:18 AM
Muhammad Hussein
Muhammad Hussein - avatar
2 Respuestas
+ 5
while(true){ int n; std::cin>>n; if(n<0) break; }
14th Aug 2020, 5:26 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
Try to check every input - if input < 0, break your loop. Like this: int x = 0; while(x>=0){ cin >> x; }
14th Aug 2020, 5:26 AM
Monat15
Monat15 - avatar