Found 27758 Articles for Server Side Programming

Float and Double in C

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

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

Difference between getc(), getchar(), getch() and getche()

Samual Sam
Updated on 24-Jun-2020 11:07:13

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

printf(), sprintf() and fprintf() in C

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

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

How to print % using printf()?

Samual Sam
Updated on 24-Jun-2020 11:08:21

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

What is the use of %n in printf()?

karthikeya Boyini
Updated on 24-Jun-2020 11:08:45

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

puts() vs printf() for printing a string in C language

Samual Sam
Updated on 24-Jun-2020 11:09:13

2K+ Views

The function puts() and printf() are declared in stdio.h header file and are used to send the text to the output stream. Both have different usages and syntax.puts()The function puts() is used to print the string on the output stream with the additional new line character ‘’. It moves the cursor to the next line. Implementation of puts() is easier than printf().Here is the syntax of puts() in C language, puts(“string”);If you do not want the cursor to be moved to the new line, use the following syntax.fputs(string, stdout)Here is an example of puts() in C language, Example Live Demo#include int ... Read More

“register” keyword in C

karthikeya Boyini
Updated on 24-Jun-2020 10:59:13

8K+ Views

Register variables tell the compiler to store the variable in CPU register instead of memory. Frequently used variables are kept in registers and they have faster accessibility. We can never get the addresses of these variables. “register” keyword is used to declare the register variables.Scope − They are local to the function.Default value − Default initialized value is the garbage value.Lifetime − Till the end of the execution of the block in which it is defined.Here is an example of register variable in C language, Example Live Demo#include int main() {    register char x = 'S';    register int ... Read More

Scope Rules in C

Samual Sam
Updated on 24-Jun-2020 10:59:47

215 Views

In C language, scope is a region of program where identifiers or variables are directly accessible.There are two categories of scope rules in C language.Global VariablesGlobal variables are declared and defined outside any function in the program. They hold their values throughout the lifetime of program. They are accessible throughout the execution of program.Here is an example of global variables in C language, Example Live Demo#include int s; int main () {    int a = 15;    int b = 20;    s = a+b;    printf ("a = %d b = %d s = %d", a, b, s); ... Read More

ftell() in C

karthikeya Boyini
Updated on 24-Jun-2020 11:00:53

10K+ Views

In C language, ftell() returns the current file position of the specified stream with respect to the starting of the file. This function is used to get the total size of file after moving the file pointer at the end of the file. It returns the current position in long type and file can have more than 32767 bytes of data.Here is the syntax of ftell() in C language, long int ftell(FILE *stream)Here is the parameter used in ftell(), stream − This is the pointer to a FILE object that identifies the stream.Here is an example of ftell() in C ... Read More

Bitwise Operators in C

karthikeya Boyini
Updated on 24-Jun-2020 11:01:54

364 Views

Bitwise operators are used to perform bit-level operations on two variables. Here is the table of bitwise operators in C language,OperatorsName of Operators&Bitwise AND|Bitwise OR^Bitwise XOR~Bitwise complementShift rightHere is an example of bitwise operators in C language,Example Live Demo#include int main() {    int x = 10;    int y = 28;    int i = 0;    printf("Bitwise AND : %d", x&y);    printf("Bitwise OR : %d", x|y);    printf("Bitwise XOR : %d", x^y);    printf("Bitwise Complement : %d,%d", ~x,~-y);    for(i;i>i);    for(i;i

Advertisements