#include <stdio.h> #include <stdlib.h> int main() { int a[5]; //array int i=0; int temp,rem=0; for(i=0;i<5;i++) { scanf("%d",&a[i]); //taking input from user while(a[i]/10!=0) { rem=a%10; //condition check but this part is not working temp++; //increasing temp one by one a[i]=a[i]/10; //dividing the no by 10 } if(temp==4) { printf("no is acceptable "); //if digit is of 4 then no //is acceptable temp=0; } else { printf("please again enter the 4 digit no"); scanf("%d",&a[i]); //again scan the no and again check the //condition while(a[i]/10!=0) { rem=a%10; temp++; a[i]=a[i]/10; } if(temp==4) { printf("no is acceptable "); //if count is 4 //then only no is acceptable temp=0; } } } for(i=0;i<5;i++) { printf("%d",a[i]); //printing the no } return 0; }
if (a[i]>=1000 && a[i]<=9999) { ... }
if (a[i] >= 1000 && a[i] <= 9999) { // It has four digits ... }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)