- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 7346 Articles for C++
510 Views
exit()The function exit() is used to terminate the calling function immediately without executing further processes. As exit() function calls, it terminates processes. It calls the constructor of class only. It is declared in “stdlib.h” header file in C language. It does not return anything.The following is the syntax of exit()void exit(int status_value);Here, status_value − The value which is returned to parent process.The following is an example of exit()Example Live Demo#include #include int main() { int x = 10; printf("The value of x : %d", x); exit(0); printf("Calling of exit()"); return 0; }OutputThe value of ... Read More
2K+ Views
exit()The function exit() is used to terminate the calling function immediately without executing further processes. As exit() function calls, it terminates processes. It is declared in “stdlib.h” header file. It does not return anything.Here is the syntax of exit() in C language, void exit(int status_value);Here, status_value − The value which is returned to parent process.Here is an example of exit() in C language, Example Live Demo#include #include int main() { int x = 10; printf("The value of x : %d", x); exit(0); printf("Calling of exit()"); return 0; }OutputThe value of x : 10In the ... Read More
13K+ 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. Here is the syntax of static keyword in C++ language, static datatype variable_name = ... Read More
589 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
611 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
1K+ Views
Here is an example of swapping in C language, Example Live Demo#include int main() { int a = 28, b = 8; a += b -= a = b - a; // method 1 printf("After Swapping : %d\t%d", a, b); (a ^= b), (b ^= a), (a ^= b); // method 2 printf("After Swapping again : %d\t%d", a, b); return 0; }OutputAfter Swapping : 828 After Swapping again : 288In the above program, there are two variables a and b and initialized with the values 28 and 8 respectively. There are so many methods ... Read More
691 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
3K+ Views
Pointers store the memory addresses. Wild pointers are different from pointers i.e. they also store the memory addresses but point the unallocated memory or data value which has been deallocated. Such pointers are known as wild pointers.A pointer behaves like a wild pointer when it is declared but not initialized. That is why, they point any random memory location.Here is an example of wild pointers in C++ language,Example Live Demo#include using namespace std; int main() { int *arr; for(int i=0; i
652 Views
There is an option that we can implement our own sizeof() operator. The operator sizeof() is a unary operator and is used to calculate the size of any type of data. We can use #define directive to implement our own sizeof() operator which will work exactly same as sizeof() operator.Here is the syntax to implement own sizeof() operator, #define Any_name(object) (char *)(&object+1) - (char *)(&object)Here, Any_name − The name you want to give to your own sizeof() operator.Here is an example to implement sizeof() operator in C language, Example Live Demo#include #define to_find_size(object) (char *)(&object+1) - (char *)(&object) int main() ... Read More