Counter Help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Counter Help

madjmmadjm Posts: 2Member
Hey guys i love the community you guys have here !

On to the problem i have a simple little program here it repeats using a do while loop i have a counter in the loop that should be counting and displays that value when the program is stoped.
For some reason the counter is not working what am i doing wrong here is the code.[code] #include
#include
#include
int main()
{

int num1,cnt;
char repeat;
cnt = 0 ;

do {
printf("
Enter a number");
scanf("%d",&num1);


printf("
Enter a next number [y] yes or no [no]");
scanf("%s",&repeat);
cnt = cnt + 1; // Here is counter //
}

while ( repeat != 'n');

system("cls");
printf("You ran the program %d",cnt);
printf("times");

getch();

}
[/code]
Sign In or Register to comment.