(Solved):Your task in this problem is to write a program (in C) that reads in integers from the user and writes out the equivalent value in figures on the next line, stopping when the user enters any negati… View Answer…

 

Question

Your task in this problem is to write a program (in C) that reads in integers from the user and writes out the equivalent value in figures on the next line, stopping when the user enters any negative number.

 

EXPERT ANSWER

#include<stdio.h>
main()
{
int num;
while(true)
{
scanf("%d", &num);
if(num >= 0)
printf("%dn", num);
else
break;
}
}

Here, we have used an infinite while loop (with loop condition always “true”). In each iteration of the loop, an

Scroll to top