- 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 1452 Articles for C
198 Views
Break statement is also a loop control statement. It is used to terminate the loop. As the break statement is encountered, the loop stops there and execute the next statement below the loop. It is also used in switch statement to terminate the case.Here is the syntax of break statement in C language, break;Here is an example of break statement in C language, Example Live Demo#include int main () { int a = 50; while( a < 60 ) { if( a == 55) { break; } ... Read More
96 Views
Continue statement is loop control statement. It works opposite the break statement and force to execute the next statements.Here is the syntax of continue statement in C language,continue;Here is an example of continue statement in C language,Example Live Demo#include int main () { int a = 50; do { if( a == 55) { a = a + 1; continue; } printf("Value of a: %d", a); a++; } while( a < 60 ); return 0; }OutputValue of a: 50 Value of a: 51 Value of a: 52 Value of a: 53 Value of a: 54 Value of a: 56 Value of a: 57 Value of a: 58 Value of a: 59
276 Views
The goto statement is a jump statement. Within a function, it is used to jump from one statement to another. The use of this statement is highly discouraged. It makes the program complex and difficult to trace the control flow of program. It makes hard to modify the program.Here is the syntax of goto statement in C language, goto label; . . . label: statement;Here is an example of goto statement in C language, Example Live Demo#include int main () { int a = 10; LOOP:do { if( a == 12) { ... Read More
50K+ 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
26K+ Views
The function strcmp() is a built-in library function and it is declared in “string.h” header file. This function is used to compare the string arguments. It compares strings lexicographically which means it compares both the strings character by character. It starts comparing the very first character of strings until the characters of both strings are equal or NULL character is found.If the first character of both strings are equal, it checks second character and so on. This process will be continued until NULL character is found or both characters are unequal.Here is the syntax of strcmp() in C language, int ... Read More
3K+ Views
The function strcpy() is a standard library function. It is used to copy one string to another. In C language, it is declared in “string.h” header file while in C++ language, it is declared in cstring header file. It returns the pointer to the destination.Here is the syntax of strcpy() in C language, char* strcpy(char* dest, const char* src);Some key points of strcpy().It copies the whole string to the destination string. It replaces the whole string instead of appending it.It won’t change the source string.Here is an example of strcpy() in C language, Example Live Demo#include #include int main() { ... Read More
4K+ Views
All these functions read the character from input and return an integer. The value of EOF is used for this purpose.getc()It reads a single character from the input and return an integer value. If it fails, it returns EOF.Here is the syntax of getc() in C language, int getc(FILE *stream);Here is an example of getc() in C language, Example Live Demo#include int main () { char val; printf("Enter the character: "); val = getc(stdin); printf("Character entered: "); putc(val, stdout); return(0); }OutputEnter the character: a Character entered: agetchar()The function getchar() reads the character from the standard ... Read More
3K+ Views
printf()The function printf() is used to print the message along with the values of variables.Here is the syntax of printf() in C language, printf(const char *str, ...);Here is an example of printf() in C language, Example Live Demo#include int main() { int a = 24; printf("Welcome! "); printf("The value of a : %d", a); getchar(); return 0; }OutputWelcome! The value of a : 24sprintf()The function sprintf() is also known as string print function. It do not print the string. It stores the character stream on char buffer. It formats and stores the series of characters and ... Read More
4K+ Views
Generally, printf() function is used to print the text along with the values. If you want to print % as a string or text, you will have to use ‘%%’. Neither single % will print anything nor it will show any error or warning.Here is an example to print % in printf() in C language, Example Live Demo#include int main() { printf("%"); printf("%%"); getchar(); return 0; }Output%There are some other ways to print % in the text message as in the following example, Example Live Demo#include #include int main() { printf("welcome%"); printf("%%"); printf("%c", '%'); ... Read More
4K+ Views
In C language, %n is a special format specifier. It cause printf() to load the variable pointed by corresponding argument. The loading is done with a value which is equal to the number of characters printed by printf() before the occurrence of %n.Note − It does not print anything. Another printf() function is used to print the statement.Here is an example of %n in C language, Example Live Demo#include int main() { int s; printf("The value of %ns : ", &s); printf("%d", s); getchar(); return 0; }OutputThe value of s : 13Even if we give the ... Read More