progam that inputs a char and dislpays wether it is digit or not using logical and condition operators in c++
what have you done?
write progam in c++
ans????
#define yes 1 #define no 0 #include <iostream.h> int main(void) { char c[30]; int arr_size, result, i=0, state; cin>>"Enter your digit:= "; cout<<c<<endl; arr_size=(sizeof(c)/sizeof(c[0])); for(i; i < arr_size; i++) { if(check_digit(c[i])) state = yes; else state = no; } if(!state) cout<<It's not a digit<<endl; else cout<<It's a digit<<endl; system("\npause"); return 0; } enjoy.. int check_digit(char c) { return (c>='0' && c<='9'); }
#define yes 1 #define no 0 #include <iostream.h> int main(void) { char c[30]; int arr_size, result, i=0, state; cin>>"Enter your digit:= "; cout<<c<<endl; arr_size=(sizeof(c)/sizeof(c[0])); for(i; i < arr_size; i++) { if(check_digit(c[i])) state = yes; else state = no; } if(!state) cout<<It's not a digit<<endl; else cout<<It's a digit<<endl; system("\npause"); return 0; } int check_digit(char c) { return (c>='0' && c<='9'); }
Join our real-time social learning platform and learn together with your friends!