Printing Quotient and Remainder of two value

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#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);
}
} 
Last edited on
up
Double post
Last edited on
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.

Here's a link to a test run of your program: http://ideone.com/zdCbHx
Why it's not accepting? #include <conio.h>
and void main()

can you help me to fix that problem?
Last edited on
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.
Topic archived. No new replies allowed.