How to write a C Program to Input Number by the user between 1-100 ?
- #include <stdio.h>
- int main (void){
- int n=53;
- int a;
- int i;
- for (i=0; i<5 && a!=n; i++){
- printf("Enter number between 1-100: ");
- scanf("%d", &a);
- if (a<0 || a>100){
- printf("Number invalid, please enter a number between 1-100: \n");
- }
- else if (a=n){
- printf("You guessed the number correctly!\n");
- }
- else if (a<n){
- printf("Number is too low, try again.\n");
- }
- else if (a>n){
- printf("Number is too high, try again.\n");
- }
- }
- if (i=5){
- printf("You're a loser.");
- }
- }