+ 2
Counting n numbers using C
please help me by providing code for counting n numbers (ex- like o-9 displaying these numbers one by one by replacing it) using C
13 odpowiedzi
+ 2
tanx for ur answer
+ 2
#include <stdio.h>
int main(){
unsigned n, i;
unsigned long long sum = 0;
while(scanf("%u",&n) < 1)
puts("Bad input, try again (an unsigned integer)");
for(i = 1; i <= n; ++i, sum += i)
printf("i = %u\n",i);
printf("sum = %llu\n", sum);
return 0;
}
+ 2
#include <stdio.h>
/* for the sleep function, unix dependant */
#include <unistd.h>
int main(){
unsigned n, i;
while(scanf("%u",&n) < 1)
puts("Bad input, try again");
putchar('\n');
for(i = 0; i <= n; ++i){
printf("\r%d",i);
fflush(stdout);
sleep(1);
}
return 0;
}
+ 1
any c code ?
+ 1
thank you for the code, but this is'nt the code that i want. i think you guys dont get my question.i will tell the program once more
A c program to Displaying n elements (ex 0-9) by overwriting the number itself.
+ 1
#baptiste sir ,
ex- when i input 9 the program should print 0 -9 in one line. (1 st print 0 then overwright 0 with 1 then overright 1 with 2 .... upto 9
+ 1
The numbers should print like a video with 1 or 2 second delay
+ 1
I think u guys got what i mean.
+ 1
#swim u comes close to it
but not this when i enter 4 it should print 0-4
first it should print 0, immediatly it should replaced by 1 and then replace 1 by 2 and so on upto 4
this should execute like a loop manner it should continuesly run
+ 1
Obviously, my last solution (with sleep and fflush) does not work on sololearn
0
In which way, overwriting?