Hi,
I just started learning c and i was if anyone could i can print the number of runs from the code below at the end instate of after each run.
Thanks!!
Code:#include <stdio.h> //printf #include <string.h> //strcmp int main(){ int x,y,runs,best=0,count=0; while ( scanf("%d", &x) == 1 ) { if(x!=NULL) { runs++; printf("%s"," "); printf("%s","("); printf("%d", x); printf("%s",")"); } printf("%d Number runs: ", runs); } } /* sample input: 3 2 2 2 1 1 2 2 Sample output: (3) (2 2 2) (1 1 2 2) Number runs: 3 */ Instate i get this output: (3)Number runs: 1(222)Number runs: 2(1122)Number runs: 3



LinkBack URL
About LinkBacks


