Simple Division Program Example in C Programming

Algorithm


  1. Take Three Variables - number1, number2 and division.
  2. Assign values on number1 and number2.
  3. Make division = number2 / number1.
  4. Print division 's value.

Code Examples

#1 Simple Division Program in C

Code - C Programming

#include <stdio.h>
int main(){
  float division = 0;
  float number1 = 100, number2 = 200;
  division = number2 / number1;
  printf("Division = %f\n",  division);
  return 0;
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
Division = 100

#2 Simple Division in C with Input

Code - C Programming

#include <stdio.h>
int main(){
  float division = 0;
  float number1, number2 = 0;
  printf("Enter Number 1: ");
  scanf("%f", &number1);
  printf("Enter Number 2: ");
  scanf("%f", &number2);
  division= number2 / number1;
  printf("Division = %.3f\n",  division);
  return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
50 5

Output

x
+
cmd
Division = 10

#3 Code with only two variables and Input

Code - C Programming

#include <stdio.h>
int main(){
  float number1, number2 = 0;
  printf("Enter Number 1: ");
  scanf("%f", &number1);
  
  printf("Enter Number 2: ");
  scanf("%f", &number2);
  
  printf("Division = %.3f\n", number2 / number1);
 
  return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
Enter Number 1: 10
Enter Number 2: 50

Output

x
+
cmd
Division = 5.000

Demonstration


Simple Division Program Example in C Programming.

 

Are you very beginners in Coding ? Let's try in Junilearning -

https://junilearning.com/blog/coding-projects/cpp-for-kids/

[It's a very popular Coding platform for Junior level programmers.]

Try Now in junilearning