Found 33676 Articles for Programming

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

Tapas Kumar Ghosh
Updated on 09-Jun-2025 14:48:51

39K+ Views

Both isalpha() and isdigit() are the part of C/C++ library function which can be used to check whether a given character is an alphabetical letter or a digit, respectively. These fuctions accept the given character/digit as input and determine the presence of letter or digit in correct/incorrect form. What is isalpha() in C/C++? The isalpha() function 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. Syntax Following is the basic syntax of isalpha() in ... Read More

getchar_unlocked() in C

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

427 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

Tapas Kumar Ghosh
Updated on 02-Jun-2025 13:56:01

7K+ 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 EnQueue: Insertion at rear end. DeQueue(): Deletion from front end. But a priority queue doesn’t follow First-In-First-Out, but rather than each element has a priority based on the level of importance. Items with the same priority are processed on First-In-First-Out service basis. An item with higher priority ... Read More

C++ Program to Implement Circular Queue

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

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

Tapas Kumar Ghosh
Updated on 02-Jun-2025 14:18:35

3K+ 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. Following are the examples of pure vs impure functions: Pure Function: sin(), strlen(), sqrt(), max(), pow(), floor() etc. Impure Function: rand(), time(), etc. There are many pure functions in C language such as strlen(), strcmp(), strchr(), strrchr(), strstr(), toupper(), tolower(), abs(), sin(), cos(), sqrt(), exp(), log(), pow(), fabs(), etc. Here we are explaining a few pure functions with ... Read More

iscntrl() function in C++

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

138 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

Tapas Kumar Ghosh
Updated on 02-Jun-2025 14:19:25

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:59 C++ Program to Find Difference Between Two Times To find the time differences then check whether we need to borrow time, for example, adding 60 seconds if the second time has more seconds. Then just subtract the hours, minutes, and seconds of the second time from the first time to get the result. Example In this example, you will see the time difference of ... Read More

C++ Program to Swap Numbers in Cyclic Order Using Call by Reference

George John
Updated on 25-Jun-2020 09:26:39

1K+ Views

Three numbers can be swapped in cyclic order by passing them to a function cyclicSwapping() using call by reference. This function swaps the numbers in a cyclic fashion.The program to swap numbers in cyclic order using call by reference is given as follows −Example Live Demo#include using namespace std; void cyclicSwapping(int *x, int *y, int *z) {    int temp;    temp = *y;    *y = *x;    *x = *z;    *z = temp; } int main() {    int x, y, z;    cout > y >> z;    cout

Static Data Members in C++

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

24K+ Views

Static data members are class members that are declared using the static keyword. There is only one copy of the static data member in the class, even if there are many class objects. This is because all the objects share the static data member. The static data member is always initialized to zero when the first class object is created.The syntax of the static data members is given as follows −static data_type data_member_name;In the above syntax, static keyword is used. The data_type is the C++ data type such as int, float etc. The data_member_name is the name provided to the ... Read More

isspace() function in C++

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

4K+ Views

The isspace() function is a predefined function in ctype.h. It specifies whether the argument is a whitespace character or not. Some of the whitespace characters are space, horizontal tab, vertical tab etc.A program that implements isspace() function by counting the number of spaces in a string is given as follows −Example Live Demo#include #include using namespace std; int main() {    char str[] = "Coding is fun";    int i, count = 0;    for(i=0; str[i]!='\0';i++) {       if(isspace(str[i]))       count++;    }    cout

Advertisements