Found 35163 Articles for Programming

Clearing input buffer in C/C++

Arjun Thakur
Updated on 25-Jun-2020 09:36:21

20K+ Views

The function fflush(stdin) is used to flush or clear the output buffer of the stream. When it is used after the scanf(), it flushes the input buffer also. It returns zero if successful, otherwise returns EOF and feof error indicator is set.Here is the syntax of fflush(stdin) to clear the input buffer in C language, int fflush(FILE *stream);Here is an example of fflush(stdin) to clear the input buffer in C language, Example Live Demo#include #include int main() {    char s[20];    printf("Enter the string : ", s);    scanf("%s", s);    printf("The entered string : %s", s); ... Read More

Static Variables in C

Chandu yadav
Updated on 25-Jun-2020 09:37:01

9K+ Views

Static variables are initialized only once. The compiler persists with the variable till the end of the program. Static variables can be defined inside or outside the function. They are local to the block. The default value of static variables is zero. The static variables are alive till the execution of the program.Here is the syntax of static variables in C language, static datatype variable_name = value;Here, datatype − The datatype of variable like int, char, float etc.variable_name − This is the name of variable given by user.value − Any value to initialize the variable. By default, it is zero.Here ... Read More

Standard header files in C

George John
Updated on 04-Oct-2023 12:26:13

24K+ Views

In C language, header files contain the set of predefined standard library functions. The "#include" preprocessing directive is used to include the header files with ".h" extension in the program. Here is the table that displays some of the header files in C language, Sr.No. Header Files & Description 1 stdio.hInput/Output ... Read More

Header files “stdio.h” and “stdlib.h” in C

Ankith Reddy
Updated on 25-Jun-2020 09:39:07

14K+ Views

stdio.hThe header file stdio.h stands for Standard Input Output. It has the information related to input/output functions.Here is the table that displays some of the functions in stdio.h in C language, Sr.No.Functions & Description1printf()It is used to print the strings, integer, character etc on the output screen.2scanf()It reads the character, string, integer etc from the keyboard.3getc()It reads the character from the file.4putc()It writes the character to the file.5fopen()It opens the file and all file handling functions are defined in stdio.h header file.6fclose()It closes the opened file.7remove()It deletes the file.8fflush()It flushes the file.Here is an example of stdio.h in C language, ... Read More

islessgreater() in C/C++

George John
Updated on 25-Jun-2020 09:40:25

150 Views

The function islessgreater() is used to check that first argument is less than or greater than the second one. It is declared in “math.h” header file in C language. It returns true, if successful otherwise false.Here is the syntax of islessgreater() in C++ language, bool islessgreater(value1 , value2);Here, value1 − This is the first argument which will be checked with value2.value2 − This is the second argument which is used to check value1 and see that is less or greater.Here is an example of islessgreater() in C++ language, Example Live Demo#include #include using namespace std; int main() {    int ... Read More

Convert a C++ String to Upper Case

Chandu yadav
Updated on 25-Jun-2020 09:41:26

462 Views

Here is the program to convert a string to uppercase in C++ language,Example Live Demo#include #include using namespace std; int main() {    char s[30] = "This_is_string";    int i;    for(i=0;i=97 && s[i]

isless() in C/C++

Arjun Thakur
Updated on 25-Jun-2020 09:42:06

238 Views

The function isless() is used to check that first argument is less than the second one. It is declared in “math.h” header file in C language. It returns true if successful otherwise it returns false.Here is the syntax of isless() in C language, bool isless(value1 , value2);Here, value1 − This is the first argument which will be checked with value2.value2 − This is the second argument which is used to check value1 ans see that it is less or not.Here is an example of isless() in C language, Example Live Demo#include #include int main() {    int val1 = 48; ... Read More

isalpha() and isdigit() in C/C++

Ankith Reddy
Updated on 07-Nov-2023 13:17:18

31K+ Views

isalpha() The function isalpha() is used to check that a character is an alphabet or not. This function is declared in ctype.h header file. It returns an integer value, if the argument is an alphabet otherwise, it returns zero. Here is the syntax of isalpha() in C language, int isalpha(int value); Here, value − This is a single argument of integer type. Here is an example of isalpha() in C language − Example #include #include int main() {    char val1 = 's';    char val2 = '8';    if(isalpha(val1))    printf("The character is an alphabet"); ... Read More

getchar_unlocked() in C

George John
Updated on 25-Jun-2020 09:16:19

235 Views

The function getchar_unlocked() is deprecated in Windows because it is a thread unsafe version of getchar(). It is suggested not to use getchar_unlocked(). There is no stream lock check that’s why getchar_unlocked is unsafe. The function getchar_unlocked() is faster than getchar().Here is the syntax of getchar_unlocked() in C language, int getchar_unlocked(void);A program of getchar_unlocked() in C is as follows −Example Live Demo#include int main() {    char val;    val = getchar_unlocked();    printf("Enter the character : ");    printf("Entered character : %c", val);    return 0; }OutputHere is the outputEnter the character : a Entered character : aRead More

C++ Program to Implement Priority Queue

Chandu yadav
Updated on 30-Jul-2019 22:30:23

5K+ Views

The queue which is implemented as FIFO where insertions are done at one end (rear) and deletions are done from another end (front). The first element that entered is deleted first.Queue operations areEnQueue (int data): Insertion at rear endint DeQueue(): Deletion from front endBut a priority queue doesn’t follow First-In-First-Out, but rather than each element has a priority based on the basis of urgency.Items with the same priority are processed on First-In-First-Out service basis.An item with higher priority is processed before other items with lower priority.Class DescriptionsBegin    class Priority_Queue has following functions:    function insert() to insert items at ... Read More

Advertisements