Write C program to divide any two numbers by using if statements.

In this article we will learn how write a C program to divide any two numbers by using if statements.

divide any two numbers by using if statements

Answers:

#include<stdio.h>
#include<conio.h>
int main()
{
  int dividend;
  int divisor;
  int result;
  clrscr();
  printf("\n Enter the dividend:");
  scanf("%d",&dividend);
  printf("\n Enter the divisor:");
  scanf("%d",&divisor);
   if(dividend>divisor)
  {
   result=dividend/divisor;
   printf("\n Answer will be:%d",result);
  }
  if(dividend<divisor)
  printf("\n Sorry dividend<divisor");
  getch();
  return 0;
}

______________________________________________________

#include<stdio.h>
#include<conio.h>
int main()
{
  int dividend;
  int divisor;
  int result;
  clrscr();
  printf("\n Enter the dividend:");
  scanf("%d",&dividend);
  printf("\n Enter the divisor:");
  scanf("%d",&divisor);
   if(dividend>divisor)
  {
   result=dividend/divisor;
   printf("\n Answer will be:%d",result);
  }
  if(dividend<divisor)
  printf("\n Sorry dividend<divisor");
  getch();
  return 0;
}

______________________________________________________

Note:

If you are unable to see whole code then open this page in desktop mode.

Post a Comment (0)
Previous Post Next Post