Showing posts with label float. Show all posts
Showing posts with label float. Show all posts

22/02/2019

Find the largest number in C-Programming:

 Here we find the largest number among 3 three numbers. We first give the required code then we will explain. This programming is valid for real numbers not for complex numbers.
Find the largest number in C-Programming

Important Tools:

1. if-else

Code:

Find the largest number in C-Programming


#include<stdio.h>
int main()
{
  float a,b,c;
  printf("Enter the three numbers:");
  scanf("%f%f%f",&a,&b,&c);
  if(a>b && a>c)
  printf("%f is the largest number among %f,%f,%f",a,a,b,c);
  if(b>a && b>c)
  printf("%f is the largest number among %f,%f,%f",b,a,b,c);
  else
  printf("%f is the largest number among %f,%f,%f",c,a,b,c);
}

Output:

The output is given below:
Find the largest number in C-Programming

Explanation:

1. First of all we used header package <stdio.h>.
2. We use 3 float variables a,b,c for store the three numbers which are given by the users.
3. We use if-else here. First if is used for if a is the largest and the second if is used for if b is largest and for c we use the else case. For know more about the use of if-else command, please visit our syntax page.
4. Point that i don't use any curly bracket after the command if and else. Since only one statement are there after if command and also after else command so it not necessary to use this curly bracket. You can use it if you want there is no problem.

                                       If you have any doubts comment below.

11/02/2019

Sum of two Real numbers in C-programming: 

We are going to do sum of two real numbers in C-programming. Here you can use any C-programming software to do it. At first we give the code of this programming and then we explain it smoothly. We always try to make easy for the beginners.

                                                                                                                                                                        The code of this programme is below:                                                                   
#include<stdio.h>
#include<conio.h>
void main()
{
float a,b,add;
printf("Enter two numbers:\n");
scanf("%f%f",&a,&b);
add=a+b;
printf("the sum of %f and %f is %f",a,b,add);
getch();
}
If you run the above program then you get this output below:




EXPLANATION:

1. First of all we used two packages <stdio.h> and <conio.h>. to know the uses of <stdio.h> and <conio.h> visit our packages page.
2. we used "void main()" here you can use only "main()" if you use windows operating system or you can use "int main()" if you use Linux operating system.
know more in important syntax of our page.
3. we used three float variable a,b,add.
4. Now we use "a" and "b" for store the two given numbers and use "add" variable to give the addition value of "a" and "b".
5. Now we print the value of "add" variable and we get the output.
6. Now we use "getch()". To know more go to important syntax