- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 34494 Articles for Programming
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
2K+ Views
printf()This is mainly used in C language. It is a formatting function that prints to the standard out. It prints to the console and takes a format specifier to print. It returns an integer value. It is not type safe in input parameters. It can be used in C++ language too.Here is the syntax of printf() in C and C++ language, printf(“string and format specifier”, variable_name);Here, String − Any text/message to print on console.Format Specifier − According to the variable datatype, use format specifiers like %d, %s etc.variable_name − Any name given to declare the variable.Here is an example of ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
22K+ Views
In C language, there are three methods to convert a char type variable to an int. These are given as follows −sscanf()atoi()TypecastingHere is an example of converting char to int in C language, Example Live Demo#include #include int main() { const char *str = "12345"; char c = 's'; int x, y, z; sscanf(str, "%d", &x); // Using sscanf printf("The value of x : %d", x); y = atoi(str); // Using atoi() printf("The value of y : %d", y); z = (int)(c); // Using typecasting printf("The value of z ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
3K+ Views
The preprocessor directive #pragma is used to provide the additional information to the compiler in C/C++ language. This is used by the compiler to provide some special features.Here is the syntax of #pragma directive in C/C++ language, #pragma token_nameThe table of some of #pragma directives in C/C++ language is given as follows, Sr.No.#pragma Directives & Description1#pragma startupBefore the execution of main(), the function specified in pragma is needed to run.2#pragma exitBefore the end of program, the function specified in pragma is needed to run.3#pragma warnUsed to hide the warning messages.4#pragma GCC dependencyChecks the dates of current and other file. If ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
654 Views
Here is an example of passing array by value in C language, Example Live Demo#include float avg(float a[]) { int i; float avg, sum = 0.0; for (i = 0; i < 6; ++i) { sum += a[i]; } avg = (sum / 6); return avg; } int main() { float avg1, a[] = {63, 21, 34.4, 12.5, 3, 2.2}; avg1 = avg(a); printf("Average : %f", avg1); return 0; }OutputHere is the outputAverage : 22.683332In the above program, The actual code of calculating average is ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
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
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
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
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
61K+ 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]
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
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
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
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
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
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