Write a C program which perform division operation and exit the program if someone enters 0

 TASK-

Write a  C program which perform division operation and exit the program if someone enters 0



CODE:


#include<stdio.h>
int div(int n,int d);


int main(){
int num,deno=2,m=9;


printf("Enter nominator: ");
scanf("%d",&num);


 do 
 {
  num=div(num,deno);
  printf("\nAfter dividing nominator by 2 the new answer is %d",num);
  printf("\n\nif you want to stop the division Enter zero else enter any number: ");
scanf("%d",&m);
 }while (m!=0);


getchar();
return 0;
}
int div(int n,int d)
{
n=n/d;
return n;
}

EXPECTED OUTPUT:




NEED WORK PRODUCE WORK

My name is Abdul Rehman I am from Pakistan. I am doing BS in Computer and information sciences. Currently, I am creating these blogs to help students of computer sciences all over the world..

Post a Comment (0)
Previous Post Next Post