
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
Found 33676 Articles for Programming

723 Views
The threa_cancel() is used to cancel one particular thread by the thread id. This function sends one cancellation request to the thread for termination. The syntax of the pthread_cancel() is like below −int pthread_cancel(pthread_t th);Now, let us see how to cancel threads using this function.Example#include #include #include #include int count = 0; pthread_t sample_thread; void* thread_one_func(void* p) { while (1) { printf("This is thread 1"); sleep(1); // wait for 1 seconds count++; if (count == 5) { //if the ... Read More

273 Views
Here we will see the effect of nextafter() and nextforward() functions in C or C++. These functions are present in the math.h or cmath library.if the functions are like nextafter(a, b) and nextforward(a, b). These functions are used to find the next representable value after a in the direction of b. The nextforward() has more precise second parameter b.Example#include #include main () { //The nextafter function() printf ("Smallest representable number after 0 towards 1 : %e", nextafter(0.0, 1.0)); printf ("Largest representable number before -1 towards 0 :%e", nextafter(0.0, -1.0)); printf ("Largest +ve representable number ... Read More

408 Views
Here we will see some interesting facts about C programming. These are like below.Sometimes the case labels of some switch statement can be placed inside if-else statement.Example#include main() { int x = 2, y = 2; switch(x) { case 1: ; if (y==5) { case 2: printf("Hello World"); } else case 3: { //case 3 block ... Read More

1K+ Views
In C++, there is no direct way to check the environment architecture. There are two Macros for Windows systems, that can be used to check the architecture. These macros are _WIN64, and _WIN32. When the system is 64-bit, then the _WIN64 will be 1, otherwise the _WIN32 will be 1. So using macro checking, we can identify the architectureExample#include using namespace std; int main() { #ifdef _WIN64 cout

17K+ Views
A const member variable in a C++ class is a data member whose value must be initialized during object construction and cannot be modified. Initializing Const Member Variable in C++ Class The const member variable must be initialized. To initialize a const member variable, you can use a member initializer list using a constructor, . The member initializer list is the special way to initialize the values to class variables while creating an object before the constructor block runs. Note: If the member is static and of an integer type, you can directly initialized with the class definition. ... Read More

14K+ Views
The CTRL + C is used to send an interrupt to the current executing task. In this program, we will see how to catch the CTRL + C event using C++.The CTRL + C is one signal in C or C++. So we can catch by signal catching technique. For this signal, the code is SIGINT (Signal for Interrupt). Here the signal is caught by signal() function. Then one callback address is passed to call function after getting the signal.Please see the program to get the better idea.Example#include #include #include #include using namespace std; // Define ... Read More

7K+ Views
Here we will see, how to terminate the threads in C++11. The C++11 does not have direct method to terminate the threads.The std::future can be used to the thread, and it should exit when value in future is available. If we want to send a signal to the thread, but does not send the actual value, we can pass void type object.To create one promise object, we have to follow this syntax −std::promise exitSignal;Now fetch the associated future object from this created promise object in main function −std::future futureObj = exitSignal.get_future();Now pass the main function while creating the thread, pass ... Read More

5K+ Views
To compile multiple files like file_name.h, or file_name.cpp at once, we can use the files like a list one after another. The syntax will be like this −g++ abc.h xyz.cppTo run the program, we can use this −./a.outExamplefloat area(float r){ return (3.1415*r*r); //area of a circle } float area(float l, float w){ return (l * w); //area of a rectangle }Example#include #include "area.h" using namespace std; main(){ cout

1K+ Views
To add libraries in Visual Studio 2012, there are two different methods. The first one is manual method. The second one is adding libraries from code.Let us see the manual method first.To add some library, we have to follow these five steps −Add the #include statements necessary files with proper declarations. For example −#include “library.h”Add the include directory for the compiler look up;Go to the Configuration Properties/VC++ Directories/Include DirectoriesThen click and edit, and add new entryAdd one library directory for *.lib files:Go to project (on top bar) -> properties -> Configuration Properties -> VC++ Directories -> Library Directories, then click ... Read More

14K+ Views
Here we will see how to compare two floating point data using C++. The floating point comparison is not similar to the integer comparison.To compare two floating point values, we have to consider the precision in to the comparison. For example, if two numbers are 3.1428 and 3.1415, then they are same up to the precision 0.01, but after that, like 0.001 they are not same.To compare using this criteria, we will find the absolute value after subtracting one floating point number from another, then check whether the result is lesser than the precision value or not. By this we ... Read More