Number Catching Game| C Languange|Busy

in #busy7 years ago

Basic game for c learners

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main (void)
{

int playerNum, n,randNum,looop=1,loop=1,sum=0;
srand(time(NULL));



    
randNum=rand()%1000;
printf("Please enter a number for start:");


do{
scanf("%d",&playerNum);
sum++;
    
if(playerNum==randNum)
{
printf("Congrt, you find it %d",sum);

loop=0;
}
else if(playerNum>randNum)
{
    printf("Make smaller");
}
else
{
    printf("Make higher");
}

}while(loop==1);

return 0;

}

Sort:  

i love the lay out of c program though it looks better when you use a dowhile(loop==1)

This post has received a 0.42 % upvote from @morwhale thanks to: @onlyblack.

Release the Kraken! You got a 1.02% upvote from @seakraken courtesy of @onlyblack!

You got a 0.80% upvote from @mercurybot courtesy of @onlyblack!

You just planted 0.03 tree(s)!


Thanks to @onlyblack

We have planted already 7401.68 trees
out of 1,000,000


Let's save and restore Abongphen Highland Forest
in Cameroonian village Kedjom-Keku!
Plant trees with @treeplanter and get paid for it!
My Steem Power = 18431.77
Thanks a lot!
@martin.mikes coordinator of @kedjom-keku
treeplantermessage_ok.png