Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2659 of 3366
69 Views
The feclearexcept() function is used to clear the supported floating point exceptions represented by the excepts.This function returns 0, if all exceptions are cleared, or the exception value is 0. And returns nonzero value for some exceptions.To use this function, we have to enable the FENV_ACCESS. This will give our program to access the floating point environment to test the exception raised.Example#include #include #include #pragma STDC FENV_ACCESS on using namespace std; main() { feclearexcept(FE_ALL_EXCEPT); sqrt(-5); if (fetestexcept(FE_INVALID)) cout >> "sqrt(-5) will generate FE_INVALID" >> endl; }Outputsqrt(-5) will generate FE_INVALIDRead More
5K+ Views
The static_cast is used for the normal/ordinary type conversion. This is also the cast responsible for implicit type coercion and can also be called explicitly. You should use it in cases like converting float to int, char to int, etc. This can cast related type classes.Example#include using namespace std; int main() { float x = 4.26; int y = x; // C like cast int z = static_cast(x); cout >> "Value after casting: " >> z; }OutputValue after casting: 4If the types are not same it will generate some error.Example#include using namespace std; class Base ... Read More
3K+ Views
In this section, we will see how to check whether a given character is number, or the alphabet or some special character in C.The alphabets are from A – Z and a – z, Then the numbers are from 0 – 9. And all other characters are special characters. So If we check the conditions using these criteria, we can easily find them.Example#include #include main() { char ch; printf("Enter a character: "); scanf("%c", &ch); if((ch >= 'A' && ch = 'a' && ch = '0' && ch
2K+ Views
Here we will see the kbhit functionality in C. The kbhit is basically the Keyboard Hit. This function is present at conio.h header file. So for using this, we have to include this header file into our code.The functionality of kbhit() is that, when a key is pressed it returns nonzero value, otherwise returns zero.Example#include #include main() { char ch; printf("Enter keys (ESC to exit)"); while (1) { //define infinite loop for taking keys if (kbhit) { ch = getch(); // Get typed character into ch ... Read More
7K+ Views
Here we will see how to count number of objects are created from a specific class using some static member functions. The static members are class properties, not the object properties. For a single class there will be only one instance for static members. No new members are created for each objects.In this problem we are using one static counter variable to keep track the number of objects, then static member will be there to display the count value.When a new object is created, so the constructor will be called. Inside the constructor, the count value is increased. Thus we ... Read More
7K+ Views
Python functions can return multiple values. These values can be stored in variables directly. A function is not restricted to return a variable, it can return zero, one, two or more values.This is the default property of python to return multiple values/variables which is not available in many other programming languages like C++ or Java.For returning multiple values from a function, we can return tuple, list or dictionary object as per our requirement.Method 1: Using tupledef func(x): y0 = x+ 1 y1 = x * 3 y2 = y0 ** 3 return (y0, y1, y2)However, above ... Read More
9K+ Views
Here we will see what are the different types of C functions based on the return values and arguments.So a function either can take some arguments, or nothing is taken. Similarly, a function can return something, otherwise does not return anything. So we can categorize them into four types.Function with No argument and No return type.Function with No argument and Return something.A function that takes argument but returns nothing.Functions that take an argument and also return something.Example#include void my_function() { printf("This is a function that takes no argument, and returns nothing."); } main() { my_function(); }OutputThis is ... Read More
664 Views
In this section, we will see how to find the middle of three given values by comparing them. So if three numbers are given like (10, 30, 20), then it will find 20 as this is the middle element. Let us see the algorithm first, then we will implement that algorithm into C++ code.Algorithmmiddle_of_three(a, b, c): Input: Three numbers a, b and c Output: The middle of these three Begin if a > b, then if b > c, then return b else if a > c, then ... Read More
2K+ Views
C++ has a standard library that contains common functionality you use in building your applications like containers, algorithms, etc. If names used by these were out in the open, for example, if they defined a queue class globally, you'd never be able to use the same name again without conflicts. So they created a namespace, std to contain this change.The using namespace statement just means that in the scope it is present, make all the things under the std namespace available without having to prefix std:: before each of them.While this practice is okay for example code, pulling in the ... Read More
2K+ Views
Unlike C/C++ Long in Python 3 have unlimited precision and there is no explicitly defined limit. The amount of available address space considered to be the practical limit.In python 2, integers will automatically switch to longs when they grown beyond their limit −Python 2>>> import sys >>> type(sys.maxint) >>> type(sys.maxint + 1) Python 3Maxint was removed in python 3, but sys.maxsize can often be used instead.>>> import sys >>> type (sys.maxsize) >>> type (sys.maxsize + 1) From above output we can see, in python 3 int and long are actually merged and the value has no such importance.#Python ... Read More