Write an algorithm that computes and displays the quotient and remainder of B divided by A. However, do not perform the operation if the divisor is zero, instead, display a message.
#include <stdio.h>
#include <conio.h>
int a,b;
int resultq,resultr;
void main ()
{
clrscr ();
printf ("Input the first value : ");
scanf ("%d", &a);
printf ("Input the second value : ");
scanf ("%d",&b);
if(a<=0 ||b<=0){
printf("First and Second value should be a positive value");
}
else{
resultq = b / a;
resultr = b % a;
printf("The quotient of the first and second value is: ", resultq);
printf("The remainder of the first and second value is: ", resultr);
}
}
If you need to test code outside of an IDE, I'd recommend http://ideone.com
Your printf statements on lines 22 and 23 don't print the values because you didn't tell them to. (This is fixed in the link below)
As a side note - the website will not allow you to include "conio.h" or use "void main()" or anything else windows-specific like "system("pause");". These problems have also been fixed in the link below.
It shouldn't be a problem because you shouldn't be using conio.h or void main().
Conio.h isn't part of the standard library - meaning that not all compilers come packaged with it. The compiler that the website uses doesn't have it.
void main() is just wrong. main should ALWAYS return int according to the standard. Only some compilers allow the use of the former. The website's does not.
Write code that complies with the standard in order to use the website.