Found 1339 Articles for C

scanf() and fscanf() in C

karthikeya Boyini
Updated on 24-Jun-2020 11:17:07

2K+ Views

Function scanf()The function scanf() is used to read formatted input from stdin in C language. It returns the whole number of characters written in it otherwise, returns a negative value.Here is the syntax of scanf() in C language, int scanf(const char *characters_set)Here is an example of scanf() in C language, Example Live Demo#include int main () {    char s[20];    printf("Enter a string : ");    scanf("%s", s);    printf("Entered string : %s", s);    return(0); }OutputEnter a string : Peter! Entered string : Peter!Function fscanf()The function fscanf() is used to read the formatted input from the given stream ... Read More

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

756 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

233 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

267 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

221 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

800 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

Convert a String to Uppercase in C

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

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

459 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

Float and Double in C

karthikeya Boyini
Updated on 02-Sep-2023 14:14:10

56K+ Views

FloatFloat is a datatype which is used to represent the floating point numbers. It is a 32-bit IEEE 754 single precision floating point number (1-bit for the sign, 8-bit for exponent, 23*-bit for the value. It has 6 decimal digits of precision.Here is the syntax of float in C language, float variable_name;Here is an example of float in C language, Example Live Demo#include #include int main() {    float x = 10.327;    int y = 28;    printf("The float value : %f", x);    printf("The sum of float and int variable : %f", (x+y));    return 0; }OutputThe float value ... Read More

Advertisements