I'm Rajesh.
I'm new to coding.
I'm using 'Let us C' book to learn C myself.
So I need help from experts.
Please check code below. I have mentioned the problem too below.
Above is the code I wrote.Code:/*Check wheather the entered number is prime.*/ #include<stdio.h> #include<math.h> main( ) { int mod, i, num, div; char repeat='y'; while (repeat=='y') { printf("Enter the number:"); scanf("%d",&num); div=pow(num,0.5); /*printf("%d",div);*/ for (i=2;i<=div;i++) { mod=num%i; if(mod==0) { printf("%d is not a prime number\n",num); break; } } if(mod!=0) printf("%d is a prime number\n",num); printf("Do you want to enter another number?(y/n):"); scanf("%c",repeat); } }
The programming in running once correctly, but it's not looping. ie., it is not even giving me an option to type y/n. Can someone help me for this?
Thanks,
Rajesh.



LinkBack URL
About LinkBacks




