Found 34549 Articles for Programming

swap() function in C++

Samual Sam
Updated on 24-Jun-2020 11:22:01

21K+ Views

The swap() function is used to swap two numbers. By using this function, you do not need any third variable to swap two numbers.Here is the syntax of swap() in C++ language, void swap(int variable_name1, int variable_name2);If we assign the values to variables or pass user-defined values, it will swap the values of variables but the value of variables will remain same at the actual place.Here is an example of swap() in C++ language, Example Live Demo#include using namespace std; int main() {    int x = 35, y = 75;    printf("Value of x :%d", x);    printf("Value of ... Read More

iswdigit() function in C/C++

karthikeya Boyini
Updated on 24-Jun-2020 11:09:44

157 Views

The function iswdigit() is a built-in function in C/C++. It checks whether the wide character is a decimal digit or not. It is declared in “cwctype” header file in C++ language while “ctype.h” in C language. It takes a single character which is known as wide character.The characters from 0 to 9 are classified as decimal digits. If the wide character is not a digit, it will return zero(0). If character is digit, it will return non-zero value.Here is the syntax of iswdigit() in C++ language, int iswdigit(ch)Here is an example of iswdigit() in C++ language, Example Live Demo#include #include ... Read More

towupper() function in C/C++

Samual Sam
Updated on 24-Jun-2020 11:10:04

164 Views

The function iswupper() is a built-in function in C/C++. It converts the wide character into upper case. It is declared in “cwctype” header file in C++ language while “ctype.h” in C language. It takes a single character which is known as wide character. If the character is upper case, it is converted into it, otherwise no modifications happen.Here is the syntax of towupper() in C++ language, wint_t towupper( wint_t ch );Here is an example of towupper() in C++ language, Example#include #include #include using namespace std; int main() {    wchar_t s[] = L"hello world!";    wcout Read More

iswlower() function in C/C++

karthikeya Boyini
Updated on 24-Jun-2020 11:10:43

150 Views

The function iswlower() is a built-in function in C/C++. It checks whether the wide character is in lower case or not. It is declared in “cwctype” header file in C++ language while “ctype.h” in C language. It takes a single character which is known as wide character. It will return zero(0), if the character is not a lower case character. It will return non-zero value, if character is lower case.Here is the syntax of iswlower() in C/C++ language, int iswlower(ch);Here is an example of iswlower() in C++ language, Example Live Demo#include #include using namespace std; int main() {   ... Read More

What is Array Decay in C++?

Samual Sam
Updated on 24-Jun-2020 11:11:21

2K+ Views

The loss of type and dimensions of an array is known as array decay. It occurs when we pass the array into a function by pointer or value. First address is sent to the array which is a pointer. That is why, the size of array is not the original one.Here is an example of array decay in C++ language,Example Live Demo#include using namespace std; void DisplayValue(int *p) {    cout

How to use enums in C/C++?

karthikeya Boyini
Updated on 24-Jun-2020 11:11:44

715 Views

Enumeration is a user defined datatype in C language. It is used to assign names to the integral constants, which makes a program easy to read and maintain. The keyword “enum” is used to declare an enumeration.Here is the syntax of enum in C language, enum enum_name{const1, const2, ....... };The enum keyword is also used to define the variables of enum type. There are two ways to define the variables of enum type as follows.enum week{sunday, monday, tuesday, wednesday, thursday, friday, saturday}; enum week day;Here is an example of enum in C language, Example#include enum week{Mon=10, Tue, Wed, Thur, Fri=10, ... Read More

Strings in C Language

Samual Sam
Updated on 24-Jun-2020 11:12:17

1K+ Views

String is an array of characters and terminated by a null character (\0). The null character is not placed by the user, the compiler places it at the end of string automatically.The difference between an array and a string is that the compiler does not place null character at the end of array while in string, compiler places null character.Here is the syntax of string in C language, char myStr[size];Here, myStr: The stringsize: Set the size of stringInitialize string in C language like show below −char myStr[size] = “string”; char myStr[size] = { ‘s’, ’t’, ’r’, ’i’, ’n’, ’g’, ’\0’ ... Read More

Arrays in C Language

karthikeya Boyini
Updated on 24-Jun-2020 11:12:39

855 Views

Array is a collection of same type of elements at contiguous memory location. The lowest address corresponds to the first element while highest corresponds to last element.Array index starts with zero(0) and ends with the size of array minus one(array size - 1). Array size must be integer greater than zero.Let us see an example, If array size = 10 First index of array = 0 Last index of array = array size - 1 = 10-1 = 9Here is the syntax of arrays in C language, type array_name[array_size ];The following is how you can initialize an array.type array_name[array_size] = ... Read More

Convert a String to Uppercase in C

Samual Sam
Updated on 04-Oct-2023 14:05:42

28K+ Views

Here is the program to convert a string to uppercase in C language,Example#include #include int main() {    char s[100];    int i;    printf("Enter a string : ");    gets(s);    for (i = 0; s[i]!='\0'; i++) {       if(s[i] >= 'a' && s[i] = 'a' && s[i]

For Versus While Loop in C

karthikeya Boyini
Updated on 24-Jun-2020 11:13:48

374 Views

For LoopThe for loop is a repetition control structure. It executes the statements a specific number of times. First, it takes the initial value from where it starts the iterations. Second, it takes the condition, which is checked for true, or false. At the end, it increment/ decrement and update the loop variables.Here is the syntax of for loop in C language,for ( init; condition; increment ) {    statement(s); }Here is an example of for loop in C language,Example Live Demo#include int main () {    int a = 5;    for(int i=0;i

Advertisements