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 2378 of 2650
 
			
			1K+ Views
The following is an example to print variable name.Example Live Demo#include #define VariableName(name) #name int main() { int name; char ch; printf("The variable name : %s", VariableName(name)); printf("The variable name : %s", VariableName(ch)); return 0; }OutputThe variable name : name The variable name : chIn the above program, the variable names are printed by defining the method before main()#define VariableName(name) #nameTwo variables of different datatypes are declared. By using the defined function, variable names are printed.int name; char ch; printf("The variable name : %s", VariableName(name)); printf("The variable name : %s", VariableName(ch));
 
			
			2K+ Views
The power function is used to find the power given two numbers that are the base and exponent. The result is the base raised to the power of the exponent.An example that demonstrates this is as follows −Base = 2 Exponent = 5 2^5 = 32 Hence, 2 raised to the power 5 is 32.A program that demonstrates the power function in C++ is given as follows −Example Live Demo#include using namespace std; int main(){ int x, y, ans = 1; cout > x; cout > y; for(int i=0; i
 
			
			417 Views
When static keyword is used, variable or data members or functions can not be modified again. It is allocated for the lifetime of program. Static functions can be called directly by using class name.Static variables are initialized only once. Compiler persist the variable till the end of the program. Static variable can be defined inside or outside the function. They are local to the block. The default value of static variable is zero. The static variables are alive till the execution of the program.The following is the syntax of static keyword.static datatype variable_name = value; // Static variable static ... Read More
 
			
			9K+ Views
The term Fibonacci numbers is used in mathematics, which calculates the sum of two preceding numbers that starts from 0 and 1 and continues till based on the given number say num. Mathemathematically, it is represented by: Fn = Fn-1 + Fn-2 Let us take an example to understand the above formula based on fibonacci numbers. F0 = 0 F1 = 1 F2 = F1 + F0 = 1 + 0 = 1 F3 = F2 + F1 = 1 + 1 = 2 F4 = F3 + F2 = 2 + 1 = 3 ... Read More
 
			
			1K+ Views
You are given a number and you need to write a C++ program to check whether a number can be expressed as sum of two prime numbers. Input / Output Scenarios Following is the input-output statement: Input: n = 19 Output: 19 can be expressed as the sum of two prime numbers. Explanation: 19 = 17 + 2, and both 17 and 2 are prime numbers. Input: n = 36 Output: 36 can be expressed as the sum of two prime numbers. Explanation: 36 = 31 + 5, and both 31 and 5 are prime numbers. C++ Program ... Read More
 
			
			990 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
 
			
			72K+ 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
 
			
			774 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
return statement The C++ return statement terminates the execution of function and it returns the control to the calling function. It calls the constructor as well as the destructor. It returns an integer value for “int main()”. The following is the syntax of return statement. return expression; Here, expression − The expression or any value to be returned. The following is an example of return statement. Example #include using namespace std; class Method { public: Method() { cout