Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
isnormal() function 
3.
Normal Number
4.
Example
5.
Frequently Asked Questions
5.1.
What is C++ programming language?
5.2.
What are normal numbers?
5.3.
What does isnormal() function in C++ does?
6.
Conclusion
Last Updated: Mar 27, 2024
Easy

isnormal() in C++

Author APURV RATHORE
0 upvote
Leveraging ChatGPT - GenAI as a Microsoft Data Expert
Speaker
Prerita Agarwal
Data Specialist @
23 Jul, 2024 @ 01:30 PM

Introduction

C++ is a programming language that may be used to write imperative and object-oriented code. It is a middle-level programming language. Since 1979, Bjarne Stroustrup has been working on it at Bell Labs. In 1985, it was published for the first time. It's a compiled, general-purpose, statically typed, case-sensitive, free-form programming language.

Learning C++ strengthens the fundamentals of programming and opens the door to a variety of professional options.

A skilled C++ programmer should be knowledgeable about the language's different built-in functions. One such important function in C++ is isnormal(). We will be going over the details of it in this blog. 

Also see, Literals in C, Fibonacci Series in C++

isnormal() function 

isnormal() is an inbuilt function in C++ programming language which is defined under the <cmath.h> header. This function is used to verify whether a given number is normal or not. 

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Normal Number

A number is called a normal number if it is neither infinite, zero, nor NAN. 

For example, the number 5 is a normal number, while 0 is not a normal number. 

Syntax:

bool  isnormal(double x);  
bool  isnormal(float x);  
bool  isnormal(long double x);  

 

Parameters:

Only one parameter of type float is accepted by the isnormal() function.

Return Value:

If the number provided is a normal number, then it returns 1. Else it returns 0. 

Also Read - C++ Interview Questions

Example

// example of isnormal() function.  
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    float f = 1.0F;
    //  non-zero value
    cout << "isnormal 1.0= " << isnormal(f) << endl;
 
    // infinite value
    f = 1.2F;
    cout << "isnormal(1.2/0.0) is = " << isnormal(f / 0.0) << endl;

    //  zero
    f = 0.0F;
    cout << "isnormal 0.0= " << isnormal(f) << endl;  
    return 0;
}

 

Output:

isnormal 1.0= 1
isnormal(1.2/0.0) is = 0
isnormal 0.0= 0

 

Try and compile with online c++ compiler.

Frequently Asked Questions

What is C++ programming language?

C++ is a programming language that may be used to write both imperative and object-oriented code. It is a middle-level programming language. It's a compiled, general-purpose, statically typed, case-sensitive, free-form programming language.

What are normal numbers?

A number is called a normal number if it is neither infinite, zero, nor NAN. 

For example, the number 5 is a normal number, while 0 is not a normal number. 

What does isnormal() function in C++ does?

isnormal() is an inbuilt function in C++ programming language which is defined under the <cmath.h> header. This function is used to verify whether a given number is normal or not. 

Conclusion

In this article, we have extensively discussed the about isnormal() function along with examples in C++ programming language. We hope that this blog has helped you enhance your knowledge regarding isnormal function in C++ programming language and if you would like to learn more about the C++ programming language, check out this article on Basics of C++You can refer to our guided paths on the Coding Ninjas Studio platform to learn more about important languages and core concepts. To practice and improve yourself in the interview, you can check out Top 100 SQL problemsInterview experienceCoding interview questions, and the Ultimate guide path for interviews. Do upvote our blog to help other ninjas grow. 

Happy Coding!

Live masterclass