Found 33676 Articles for Programming

C function argument and return values

Anvi Jain
Updated on 30-Jul-2019 22:30:26

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

Middle of three using minimum comparisons in C++

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

640 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

Why “using namespace std” is considered bad practice in C++

Smita Kapse
Updated on 30-Jul-2019 22:30:26

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

What is the maximum possible value of an integer in Python?

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

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

sqrt, sqrtl and sqrtf in C++

Anvi Jain
Updated on 30-Jul-2019 22:30:26

897 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

abs(), labs(), llabs() functions in C/C++

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

201 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

remainder() in C++

Smita Kapse
Updated on 30-Jul-2019 22:30:26

205 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

Implementing Web Scraping in Python with BeautifulSoup?

George John
Updated on 30-Jul-2019 22:30:26

293 Views

BeautifulSoup is a class in the bs4 module of python. Basic purpose of building beautifulsoup is to parse HTML or XML documents.Installing bs4 (in-short beautifulsoup)It is easy to install beautifulsoup on using pip module. Just run the below command on your command shell.pip install bs4Running above command on your terminal, will see your screen something like -C:\Users\rajesh>pip install bs4 Collecting bs4 Downloading https://files.pythonhosted.org/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gz Requirement already satisfied: beautifulsoup4 in c:\python\python361\lib\site-packages (from bs4) (4.6.0) Building wheels for collected packages: bs4 Building wheel for bs4 (setup.py) ... done Stored in directory: C:\Users\rajesh\AppData\Local\pip\Cache\wheels\a0\b0\b2\4f80b9456b87abedbc0bf2d52235414c3467d8889be38dd472 Successfully built bs4 Installing collected packages: bs4 Successfully installed bs4-0.0.1To verify, ... Read More

wcstoll() function in C/C++

Anvi Jain
Updated on 30-Jul-2019 22:30:26

176 Views

The wcstoll() function is used to convert the wide character string to long long integers. It sets the pointer to point to the first character after the last one. The syntax is like below.long long wcstoll(const wchar_t* str, wchar_t** str_end, int base)This function takes three arguments. These arguments are like below −str: This is the starting of a wide string.str_end: The str_end is set by the function to the next character, after the last valid character, if there is any character, otherwise null.base: This specifies the base. The base values can be of (0, 2, 3, …, 35, 36)This function ... Read More

strtol() function in C++

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

343 Views

The strol() function is used to convert the string to long integers. It sets the pointer to point to the first character after the last one. The syntax is like below. This function is present into the cstdlib library.long int strtol(const char* str, char ** end, int base)This function takes three arguments. These arguments are like below −str: This is the starting of a string.str_end: The str_end is set by the function to the next character, after the last valid character, if there is any character, otherwise null.base: This specifies the base. The base values can be of (0, 2, ... Read More

Advertisements