Float in C17 Mar 2025 | 4 min read Float is a data type that enables the user to declare variables and assign floating point values to the variable. The syntax for declaring float variableThe data type is used to declare the numbers with decimal points. Its syntax is as follows: You can also use the float keyword once to declare multiple floating point variables at once. Parameters or Arguments
For Example: Now let us see examples to learn how to use the float in your C program. Example 1: Declare the Variable In the code below, we have used the float keyword to declare the roi variable in the program. Output: ![]() Example 2: Declare the Variable and assign the value to the variable In the code below, we have declared the variable and assigned the value to the variable in a single statement. This reduces unnecessary lines of code. Output: ![]() Example 3: Declare Multiple Floating Point Variable in a single line The user can also declare multiple variables in a single line using the datatype only once. To declare multiple variables in a single statement, the user must separate the variable names by commas (,). Let us see an example to implement the statement in your code. Output: ![]() Example 4: Declaring multiple floating point variables and assigning the values to the variable in the same statement. It is possible to declare different variables simultaneously until they have the same datatype. To declare floating point variables and assign the values to the variable, use the float keyword, followed by key=value pairs of the variable name and value, each separated by a comma (,). Output: ![]() Differentiate between float and double datatype in C ProgrammingThere are two data types in C and C++ that allow users to take and return decimal point values in the system. These data types are float and double, and the user can use both these data types to represent such numbers. Now the question arises why use two different data types for representing the same type of data and what is the difference between these two data types?
Next Topicislower() in C |
Find out Power without Using POW Function in C
The function pow() is used to calculate the power of a given integer. Now in this article we will going to understand with a help of a program how to calculate the power of a integer without using the function pow() in C. Using for loop for...
4 min read
Number Triangle
C Program to print Like alphabet triangle, we can write the c program to print the number triangle. The number triangle can be printed in different ways. Let's see the c example to print number triangle. Example #include<stdio.h> #include<stdlib.h> int main(){ int i,j,k,l,n; system("cls"); printf("enter the range=");...
1 min read
Armstrong Number
in C In C programming, Armstrong's number is used to represent the sum of its own digits raised to the power of the number of digits. It is sometimes known as a pluperfect number, a narcissistic number, or a pluperfect digital invariant. These numbers are...
10 min read
realloc in C
The "realloc" is a standard library function in C that is used to resize dynamically allocated memory blocks. The function takes two arguments: a pointer to a iously allocated memory block and the new size to which the memory block needs to be resized. The function works...
7 min read
while loop vs do-while loop in C
Difference between while loop and do-while loop in C? In this article, we learn comparison between the while loop and do-while loop constructs in C language. At the beginning of this article, we understand the concept of while loop and do-while loop in C. After that, we...
4 min read
Structure Pointer in C
In this section, we will discuss the Structure pointer in the C programming language. Before going to the concepts, let's understand the Structure. The structure is the collection of different data types grouped under the same name using the struct keyword. It is also known as...
6 min read
itoa Function in C
itoa () function is used to convert int data type to string data type in C language. SYNTAX - char * itoa ( int value, char * str, int base ); The string we place in the buffer pass must be large enough to hold the output. Since radix...
2 min read
Kruskal algorithm in C
The greedy Kruskal's method searches for the quickest route through a connected weighted network. In this algorithm, we start with an empty set of edges and add edges to the set one at a time until we obtain a spanning tree. Kruskal's approach is a well-known algorithm...
5 min read
Strong number in C
A number can be said as a strong number when the sum of the factorial of the individual digits is equal to the number. For example, 145 is a strong number. Let's understand through an example. Program to check whether the number is strong or not. #include <stdio.h> int main() { ...
4 min read
Logical operator in c
Logical Operators in C In C programming, logical operators are mainly used to perform logical operations are commonly used in conditional statements and evaluation. Expressions are evaluated by logical operators, which return true (1) or false (0) based on the evaluation procedure. They are mostly used...
7 min read
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India



