Untitled
Anonymous
plain_text
04/18/2023 4:22 PM
704 B
21
Indexable
#include <stdio.h>
void main(){
//break statement
//user will enter number and as soon as he enters a negative number, the summ of all number before negative comes
//while loop
int i, j, store, sum;
printf("How many number you will enter: ");
scanf("%d", &store);
if(store>0){
i=1;
while(i<=store){
printf("Enter number: ");
scanf("%d \n", &j);
if(j<0){
break;
}
sum = sum + j;
++i;
}
printf("The sum is %d", sum);
}else{
printf("Enter a valid input");
}
}Editor is loading...