
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 7197 Articles for C++

972 Views
The following is an example to compute combinations using factorials.Example Live Demo#include using namespace std; int fact(int n) { if (n == 0 || n == 1) return 1; else return n * fact(n - 1); } int main() { int n, r, result; coutn; coutr; result = fact(n) / (fact(r) * fact(n-r)); cout

2K+ Views
A factorial of a number defines the non-negative integer say n that calculate the product of a number by every positive integer until it reaches 1. The symbol of factorial is (!). Mathematically, it is represented by: n! = n x (n-1) x (n-2) x ... x 1 For eg. factorial of an integer 30! = 265252859812191058636308480000000. 30! = 30x29x28x27x26x25x24x23x22x21x20x19x18x17x16x15x14x13x12x11x10x9x8x7x6x5x4x3x2x1 A non-negative integer is defined by any whole number that is 0 or positive (not a fraction or decimal). What is Large Number? In context of calculating the factorial number, the large number denotes the n value ... Read More

71K+ Views
The Fibonacci sequence is a sequence of numbers in which each number is the sum of the two numbers that precede it. ExampleBelow is the mathematical example to understand the logic of the Fibonacci number: Suppose, n = 3, then, F(0) = 0 F(1) = 1 F(2) = F(1) + F(0) = 1 + 0 = 1 F(3) = F(2) + F(1) = 1 + 1 = 2 .... .... So, Fibonacci numbers from F(0) to F(3): 0, 1, 1, 2.In this article, we will learn how to implement a C++ program to generate a Fibonacci series using recursion. ... Read More

729 Views
In C/C++, both exit() and _Exit() are used to terminate a program. The exit() performs cleanup like flushing output, closing files, and calling functions, while _Exit() ends the program immediately without doing any cleanup. Now, let us learn the difference between exit() and _Exit() individually in C/C++. C++ exit() Function The exit() function is used to clean up before terminating the program. It calls functions registered with atexit(), flushes file buffers, and returns control to the operating system. Syntax Following is the syntax for exit() function: void exit(int status_value); Example In this example, we print "Program is running..." and ... Read More

2K+ Views
In C and C++ programming, the exit(), abort(), and assert() functions are used for program termination and debugging. Each of these functions have different purpose and defined in different header files. In this article, we will learn these functions and their usage with the help of examples. The exit() Function In C/C++, exit() function is used to terminate the function call immediately without the executing further processes. This function is defined in (in C) and / (in C++) header file and does not return any value. Syntax Following is the basic syntax of exit() function: void exit(int status_value); Here, ... Read More

15K+ Views
When a static keyword is used, variables, data members, and functions can not be modified again. It is allocated for the lifetime of the program. Static functions can be called directly by using a class name. Key Points of Static Variables Static variables are variables that are defined using static keywords, which consist of special behavior compared to regular variables. Here we will see its key points. Static variables are initialized only once. The compiler persists the variable till the end of the program. Static variables can be defined inside or ... Read More

731 Views
The function strftime() is used to format the time and date as a string. It is declared in “time.h” header file in C language. It returns the total number of characters copied to the string, if string fits in less than size characters otherwise, returns zero.Here is the syntax of strftime() in C language, size_t strftime(char *string, size_t size, const char *format, const struct tm *time_pointer)Here, string − Pointer to the destination array.size − Maximum number of characters to be copied.format − Some special format specifiers to represent the time in tm.time_pointer − Pointer to tm structure that contains the ... Read More

792 Views
Generally, we use header files in C/C++ languages to access the built-in functions like int, char, string functions. The function printf() is also a built-in function which is declared in “stdio.h” header file and it is used to print any kind of data on console.Here is an example to print without header files in C language, Exampleint printf(const char *text, ...); int main() { printf( "Hello World" ); return 0; }OutputHello WorldIn the above program, we printed “Hello World” without using any header file in the program by declaring the printf() function. The declaration of printf() is as ... Read More

2K+ Views
In C++, swapping two variables means exchanging the values stored in them. There can be multiple ways to implement the swapping using single line statement. In this article, we are going to learn some of the approaches to swap the values. Example Let's consider the following example with input and output scenario: Input: int a = 5; int b = 6; Output: a = 6 b = 5 You can implement swapping of two variable by using the following different ways: Using Arithmetic Operator Using Tuple Using XOR Swap Two Variables Using Arithmetic Operator In ... Read More

946 Views
There are several methods to print numbers without using loops like by using recursive function, goto statement and creating a function outside main() function.Here is an example to print numbers using goto statement in C++ language,Example Live Demo#include using namespace std; int main() { int count=1; int x; cout > x; PRINT: cout