Found 1452 Articles for C

Difference between %d and %i format specifier in C

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

2K+ Views

Format Specifier %dThe format specifier %d takes integer value as a signed decimal integer value which means values should be decimal whether it is negative or positive.Here is an example of format specifier %d in C language, Example Live Demo#include int main() {    int v1 = 7456;    int v2 = -17346;    printf("The value in decimal form : %d", v1);    printf("The value in negative : %d", v2);    return 0; }OutputThe value in decimal form : 7456 The value in negative : -17346Format Specifier %iThe format specifier %i takes integer value as an integer value which means ... Read More

atol(), atoll() and atof() functions in C/C++

karthikeya Boyini
Updated on 24-Jun-2020 11:18:30

493 Views

atol() FunctionThe function atol() converts string into a long integer. It returns zero, when no conversion is performed. It returns the converted long int value.Here is the syntax of atol in C++ language,long int atol(const char *string)Here is an example of atol() in C++ language,Example Live Demo#include using namespace std; int main() {    long int a;    char str[20] = "538756";    a = atol(str);    cout

iswdigit() function in C/C++

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

148 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

156 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

140 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

How to use enums in C/C++?

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

687 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

989 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

836 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

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

359 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