Ex: Write a C program to accept two numbers from user and display division of this two numbers to the output screen. How to print division of two numbers. C program to print division of two numbers.
Input from user:
Enter the value of a&b:
20 5
Expected output:
division is: 4.0000
Step by step logic of the given program:
1. Accept two numbers from user declare variable say a & b.
2. Devide the number and store division in float variable c.
3. Print division on the output screen.
C program to print division of given two numbers:
/***C program to print division of two numbers***/
#include<stdio.h>
void main()
{
int a,b;
float c;//declaration of variables
//Get input from user
printf("Enter the value of a and b\n");
scanf("%d%d",&a,&b);
c=a/b;//logic for devide two numbers
printf("division is %f",c);//display division
}
No comments:
Post a Comment
If you have any doubts, please discuss here...👇