This blog assists in mastering C and C++ programming skills from basics to advanced levels.
Pages
▼
Friday, June 10, 2016
User input validation to check a number.
//User input validation to check a number.
#include<stdio.h> int main() { char chr; printf("Enter a number: "); scanf("%c",&chr); if(isdigit(chr)) printf("It is a number."); else printf("It is not a number."); return 0; } //Output 1 Enter a number: 5 It is a number. //Output 2 Enter a number: a It is not a number.
No comments:
Post a Comment