Found 34494 Articles for Programming

islessgreater() in C/C++

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

162 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

551 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

259 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

34K+ 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

271 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

C++ Program to Implement Circular Queue

Arjun Thakur
Updated on 25-Jun-2020 09:19:29

24K+ Views

A queue is an abstract data structure that contains a collection of elements. Queue implements the FIFO mechanism i.e the element that is inserted first is also deleted first.A circular queue is a type of queue in which the last position is connected to the first position to make a circle.A program to implement circular queue in C++ is given as follows −Example#include using namespace std; int cqueue[5]; int front = -1, rear = -1, n=5; void insertCQ(int val) {    if ((front == 0 && rear == n-1) || (front == rear+1)) {       cout

Pure Function in C++

Ankith Reddy
Updated on 25-Jun-2020 09:20:34

2K+ Views

Pure functions always return the same result for the same argument values. They only return the result and there are no extra side effects like argument modification, I/O stream, output generation etc.Some pure functions are sin(), strlen(), sqrt(), max(), pow(), floor() etc. Some impure functions are rand(), time() etc.Some programs to demonstrate some of the pure functions are as follows −strlen()The strlen() function is used to find the length of a string. This is demonstrated in the following program −Example Live Demo#include #include using namespace std; int main() {    char str[] = "Rainbows are beautiful";    int count = ... Read More

iscntrl() function in C++

Arjun Thakur
Updated on 25-Jun-2020 09:22:26

87 Views

The iscntrl() function in C++ checks if a character is a control character or not. This function is defined in ctype.h.The syntax for iscntrl() function is given as follows −int iscntrl ( int ch );Here, ch is the character that needs to be checked.A program that demonstrates iscntrl() function by counting the number of control characters in a string is given as follows −Example Live Demo#include #include using namespace std; int main() {    char str[] = "Coding\tis\tfun";    int i, count = 0;    for(i=0; str[i]!='\0';i++) {       if(iscntrl(str[i]))       count++;    }    cout

C++ Program to Calculate Difference Between Two Time Period

Chandu yadav
Updated on 25-Jun-2020 09:25:10

2K+ Views

There are two time periods provided in the form of hours, minutes and seconds. Then their difference is calculated. For example −Time period 1 = 8:6:2 Time period 2 = 3:9:3 Time Difference is 4:56:59A program that calculates the difference between two time periods is given as follows −Example Live Demo#include using namespace std; int main() {    int hour1, minute1, second1;    int hour2, minute2, second2;    int diff_hour, diff_minute, diff_second;    cout minute1 >> second1;    cout minute2 >> second2;    if(second2 > second1) {       minute1--;       second1 ... Read More

Advertisements