Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 2396 of 2650
903 Views
The CHAR_BIT is the number of bits in char. It is declared in “limits.h” header file in C++ language. It is of 8-bits per byte.Here is an example of CHAR_BIT in C++ language,Example Live Demo#include using namespace std; int main() { int x = 28; int a = CHAR_BIT*sizeof(x); stack s; cout
22K+ Views
The swap() function is used to swap two numbers. By using this function, you do not need any third variable to swap two numbers.Here is the syntax of swap() in C++ language, void swap(int variable_name1, int variable_name2);If we assign the values to variables or pass user-defined values, it will swap the values of variables but the value of variables will remain same at the actual place.Here is an example of swap() in C++ language, Example Live Demo#include using namespace std; int main() { int x = 35, y = 75; printf("Value of x :%d", x); printf("Value of ... Read More
2K+ Views
The loss of type and dimensions of an array is known as array decay. It occurs when we pass the array into a function by pointer or by value. Only the address of the first element is sent, which is treated as a pointer. As a result, the original array's size and type information are lost. Because of this decay, sizeof no longer gives the full size of the array but instead returns the size of the pointer. This can cause incorrect behavior in functions that depend on knowing the number of elements. Example of Array ... Read More
468 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
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
6K+ 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
4K+ 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
5K+ 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