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
C Articles - Page 126 of 134
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
3K+ Views
In C/C++, a wild pointer is a type of pointer that has not been initialized to a valid memory address. It points to memory that has been deallocated and is called a dangling pointer. The pointer behaves like a wild pointer when it is declared but not initialized. That is why, they point to random memory location. Syntax The basic syntax of initializing wild pointer in C/C++: int *ptr; Example of Wild Pointer In this example, we create a pointer arr that doesn't assign it any memory. Then, it tries to print 5 values from it using a loop. ... Read More
4K+ Views
You can print the numbers from 1 to 100 without a loop by using the various methods like recursive function and goto statement that print the list of integers.The following are the approaches to print the numbers from 1 to 100: Using Recursion As we know, recursion is the process of calling the function itself. Here, we use the recursive function to accept an integer and set the iteration of plus 1 without the logic of loop and get the expected outcome. Example In this example, we use an if statement to check whether the given integer is less than ... Read More
1K+ Views
Both and "limits.h" are header files in C and C++ that are used to define constants related to data type limits. Header files are usually created with a .h extension and are used to declare functions, variables, and other entities without having a main() function. You can also create custom header files in C and C++. The header file is specific to the C++ language, whereas "limits.h" belongs to the C language. Let's discuss them one by one with the help of a suitable example to understand them and their uses in a program in a better way: ... Read More
153 Views
The function isgraph() is used to check that the passed character has a graphical representation or not. It is declared in “ctype.h” header file.Here is the syntax of isgraph() in C language, int isgraph(int char);Here is an example of isgraph() in C language, Example Live Demo#include #include int main() { int a = ''; int b = '8'; int c = 's'; if(isgraph(a)) printf("The character has graphical representation"); else printf("The character isn’t having graphical representation"); if(isgraph(b)) printf("The character has graphical representation"); else printf("The character isn’t having graphical representation"); if(isgraph(c)) ... Read More
22K+ Views
In C, we have various methods to clear the console or output screen and one of them is clrscr() function. It clears the screen as function invokes. It is declared in "conio.h" header file. There are some other methods too like system (cls) and system ("clear") and these are declared in "stdlib.h" header file. Syntax Following are the list of syntaxes to clear the console in C programming language as follows: clrscr(); Or, system("cls"); Or, system("clear"); Let’s say we have "new.txt" file with the following content: 0, hell!o 1, hello! 2, gfdtrhtrhrt 3, ... Read More
197 Views
The function mbrlen() is used to get the length of multibyte character. It returns the size of multibyte character pointed by the pointer.Here is the syntax of mbrlen() in C language, size_t mbrlen(const char* pointer, size_t size, mbstate_t* state);Here, pointer − Pointer to the first byte of multibyte character.size − Number of bytes to check.state − Pointer to the object of mbstate_tHere is an example of mbrlen() in C language, Example Live Demo#include #include #include int main(void) { char a[] = "s"; mbstate_t s; int len; len = mbrlen(a, 5, &s); printf("Length of ... Read More
418 Views
The function raise() is used to send the signals to the program. The predefined function signal() is invoked. It is implemented to check whether it will ignore the signal or invoke the signal handler. This is declared in “signal.h” header file. It returns zero, if successful otherwise, non-zero value.Here is the syntax of raise() in C language, int raise(int signal)Here, signal − The signal number to be invoked.Here is an example of raise() in C language, Example Live Demo#include #include void handler(int sig) { printf("Signal received : %d", sig); } int main() { signal(SIGILL, handler); printf("Sending ... Read More
415 Views
The function atexit() is used to call the function after the normal exit of program. The program is called without any parameters. The function atexit() is called after exit(). The termination function can be called anywhere in the program. This function is declared in “stdlib.h” header file.Here is the syntax of atexit() in C language, int atexit(void (*function_name)(void))Here, function_name − The function is to be called at the time of termination of program.Here is an example of atexit() in C language, Example Live Demo#include #include void func1 (void) { printf("Exit of function 1"); } void func2 (void) { ... Read More
313 Views
The function ungetc() takes a character and pushes it back to the stream so that the character could be read again.Here is the syntax of ungetc() in C language, int ungetc(int character, FILE *stream)Here, character − The character to be pushed back to stream.stream − The pointer to the file object.Here is an example of ungetc() in C language, Example#include int main() { int c; while ((c = getchar()) != '0') putchar(c); ungetc(c, stdin); c = getchar(); putchar(c); puts(""); printf("The End!"); return 0; }Outputs a b c t h 0 ... Read More