C++ Articles

Page 283 of 597

CHAR_BIT in C++

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 1K+ Views

The CHAR_BIT is the number of bits in char. It is declared in “limits.h” header file in C++ language. It is of 8-bits per byte.Here is an example of CHAR_BIT in C++ language,Example#include using namespace std; int main() {    int x = 28;    int a = CHAR_BIT*sizeof(x);    stack s;    cout

Read More

Ceil and floor functions in C++

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 5K+ Views

The ceil FunctionThe ceil function returns the smallest possible integer value which is equal to the value or greater than that. This function is declared in “cmath” header file in C++ language. It takes single value whoes ceil value is to be calculated. The datatype of variable should be double/float/long double only.Here is the syntax of ceil function in C++ language,double ceil(double x); float ceil(float x);Here is an example of ceil function in C++ language,Example#include #include using namespace std; int main() {    float var = 1234.25;    float res;    res = ceil(var);    cout

Read More

Const member functions in C++

Samual Sam
Samual Sam
Updated on 11-Mar-2026 20K+ Views

The const member functions are the functions which are declared as constant in the program. The object called by these functions cannot be modified. It is recommended to use const keyword so that accidental changes to object are avoided.A const member function can be called by any type of object. Non-const functions can be called by non-const objects only.Here is the syntax of const member function in C++ language, datatype function_name const();Here is an example of const member function in C++, Example#include using namespace std; class Demo {    int val;    public:    Demo(int x = 0) {   ...

Read More

isspace() function in C++

Arjun Thakur
Arjun Thakur
Updated on 11-Mar-2026 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#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

Read More

getchar_unlocked() in C

George John
George John
Updated on 11-Mar-2026 474 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#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 : a

Read More

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

George John
George John
Updated on 11-Mar-2026 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#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

Read More

isless() in C/C++

Arjun Thakur
Arjun Thakur
Updated on 11-Mar-2026 419 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#include #include int main() {    int val1 = 48;   ...

Read More

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

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 16K+ 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

Do you think operator < is faster than <= in C/C++?

Arjun Thakur
Arjun Thakur
Updated on 11-Mar-2026 1K+ Views

No, the operator < takes same time to execute as operator

Read More

What is the difference between new/delete and malloc/ free in C/ C++?

Arjun Thakur
Arjun Thakur
Updated on 11-Mar-2026 2K+ Views

new/ deleteThe new operator requests for the memory allocation in heap. If the sufficient memory is available, it initializes the memory to the pointer variable and returns its address.The delete operator is used to deallocate the memory. User has the privilege to deallocate the created pointer variable by this delete operator.Here is an example of new/delete operator in C++ language,Example#include using namespace std; int main () {    int *ptr1 = NULL;    ptr1 = new int;    float *ptr2 = new float(299.121);    int *ptr3 = new int[28];    *ptr1 = 28;    cout

Read More
Showing 2821–2830 of 5,961 articles
« Prev 1 281 282 283 284 285 597 Next »
Advertisements