sleep function in c program !

hmm while working with the loops, that is so fast.. that just give us  the final output !! but if we want to put some delay in that so that
user can c that how the process is going , and that ll make ur code  looks different from the other regular codes. so try to use that(if u
want) in ur code.

for that just put :- sleep(1000)
thats it, now it will delay the process by 1sec. and start again !

Example :-
int main()
{

int i;
for(i=1;i<=10;i++)
{
//print the number
printf(“%d \n”,i);
//delay for 1sec.
sleep(1000);

}
getch();
}

have a happy coding!
“Learn, Innovate and share” -Hitesh Parmar

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s