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
Server Side Programming Articles - Page 2265 of 2650
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
915 Views
In the cmath library of C++, there are different functions for getting the square root except from sqrt. The sqrt is used basically for double type input. The others are used for float, long type data etc. Let us see the usage of these functions.The sqrt() FunctionThis function is used for double type data. So this returns square root of type double. The syntax is like below.double sqrt(double argument)Example#include #include #include using namespace std; main() { double x = 144.0; double y = 180.0; cout
214 Views
In the cstdlib library of C++, there are different functions for getting the absolute value except from abs. The abs are used basically for int type input in C, and int, long, long long in C++. The others are used for long, and long long type data etc. Let us see the usage of these functions.The abs() FunctionThis function is used for int type data. So this returns the absolute value of the given argument. The syntax is like below.int abs(int argument)Example#include #include #include using namespace std; main() { int x = -145; int y = 145; cout
210 Views
Here we will see the functionality of remainder() method of C++. The remainder() function is used to compute the floating point remainder of numerator/denominator.So the remainder(x, y) will be like below.remainder(x, y) = x – rquote * yThe rquote is the value of x/y. This is rounded towards the nearest integral value. This function takes two arguments of type double, float, long double, and returns the remainder of the same type, that was given as argument. The first argument is numerator, and the second argument is the denominator.Example#include #include using namespace std; main() { double x = ... Read More