Untitled
unknown
plain_text
2 years ago
528 B
9
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...