C++ Online Compiler
Example: C++ Program to Check Whether a Number is Integer or Not using For loop
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ Program to Check Whether a Number is Integer or Not using For loop #include <iostream> using namespace std; int main() { char random_number[100]; int f = 0; cout << "Enter the number to check itself: "; cin >> random_number; for (int i = 0; random_number[i] != 0; i++) { if (random_number[i] == '.') { f = 1; break; } } if (f) cout << endl << random_number << " is a floating-point number.\n"; else cout << endl << random_number << " is an integer number.\n"; return 0; }
16.5
Output
Clear
ADVERTISEMENTS