Found 7346 Articles for C++

Reverse a string in C/C++

Chandu yadav
Updated on 25-Jun-2020 09:32:04

1K+ Views

Here is an example to reverse a string in C language, Example#include #include int main() {    char s[50], t;    int i = 0, j = 0;    printf("Enter the string to reverse :");    gets(s);    j = strlen(s) - 1;    while (i < j) {       t = s[i];       s[i] = s[j];       s[j] = t;       i++;       j--;    }    printf("Reverse string is : %s", s);    return (0); }OutputHere is the outputEnter the string to reverse: Here ... Read More

Character arithmetic in C

George John
Updated on 25-Jun-2020 09:33:55

4K+ Views

Character arithmetic is used to implement arithmetic operations like addition and subtraction on characters in C language. It is used to manipulate the strings. When the characters are used with the arithmetic operations, it converts them into integer value automatically i.e. ASCII value of characters.Here is an example of character arithmetic in C language, Example Live Demo#include int main(){    char s = 'm';    char t = 'z' - 'y';    printf("%d", s);    printf("%c", s);    printf("%d", (s+1));    printf("%c", (s+1));    printf("%d", (s-1));    printf("%c", (s-1));    printf("%d", t);    // printf("%c", t);   ... Read More

C Program for LowerCase to UpperCase and vice-versa

Ankith Reddy
Updated on 02-Sep-2023 13:20:59

62K+ Views

Here is the program to convert a string to uppercase in C language,Example Live Demo#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] = 'A' && s[i] = 'A' && s[i]

Clearing input buffer in C/C++

Arjun Thakur
Updated on 25-Jun-2020 09:36:21

22K+ Views

The function fflush(stdin) is used to flush or clear the output buffer of the stream. When it is used after the scanf(), it flushes the input buffer also. It returns zero if successful, otherwise returns EOF and feof error indicator is set.Here is the syntax of fflush(stdin) to clear the input buffer in C language, int fflush(FILE *stream);Here is an example of fflush(stdin) to clear the input buffer in C language, Example Live Demo#include #include int main() {    char s[20];    printf("Enter the string : ", s);    scanf("%s", s);    printf("The entered string : %s", s); ... Read More

Standard header files in C

George John
Updated on 04-Oct-2023 12:26:13

25K+ Views

In C language, header files contain the set of predefined standard library functions. The "#include" preprocessing directive is used to include the header files with ".h" extension in the program. Here is the table that displays some of the header files in C language, Sr.No. Header Files & Description 1 stdio.hInput/Output ... Read More

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

Ankith Reddy
Updated on 25-Jun-2020 09:39:07

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

islessgreater() in C/C++

George John
Updated on 25-Jun-2020 09:40:25

162 Views

The function islessgreater() is used to check that first argument is less than or greater than the second one. It is declared in “math.h” header file in C language. It returns true, if successful otherwise false.Here is the syntax of islessgreater() in C++ language, bool islessgreater(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 and see that is less or greater.Here is an example of islessgreater() in C++ language, Example Live Demo#include #include using namespace std; int main() {    int ... Read More

Convert a C++ String to Upper Case

Chandu yadav
Updated on 25-Jun-2020 09:41:26

551 Views

Here is the program to convert a string to uppercase in C++ language,Example Live Demo#include #include using namespace std; int main() {    char s[30] = "This_is_string";    int i;    for(i=0;i=97 && s[i]

isless() in C/C++

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

259 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 Live Demo#include #include int main() {    int val1 = 48; ... Read More

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

Ankith Reddy
Updated on 07-Nov-2023 13:17:18

34K+ Views

isalpha() The function isalpha() 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. Here is the syntax of isalpha() in C language, int isalpha(int value); Here, value − This is a single argument of integer type. Here is an example of isalpha() in C language − Example #include #include int main() {    char val1 = 's';    char val2 = '8';    if(isalpha(val1))    printf("The character is an alphabet"); ... Read More

Advertisements