Can you help me?

I couldn't find the problem. Can you help me?

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

#include <stdio.h>

#include <stdlib.h>



int main() {

	

	float s1,s2,bolum;

	printf("Bir sayi degeri giriniz: ");

	scanf("%f",&s1);

	printf("Bir sayi degeri daha giriniz: ");

	scanf("%f",&s2);

	bolum=s1/s2;

	if(bolum%1==0)

	{

		printf("%f, %f'in tam katidir.",s2,s1);

	}

	else

	{

		printf("%f, %f'in tam kati degildir.",s2,s1);

	}

	

	return 0;

}

Last edited on
Learn to ask questions (What do you expect it to do? What is it doing wrong?)

Learn to use code tags around your code, like this:

[code]
your code here
[/code]
I'm sorry. You're right. When I push to button of comp&run, dev-c++ says that [Error] invalid operands to binary % (have 'float' and 'int') and it says that because of what I marked on the top. Thanks for understanding.
The modulus operator only works on integers. And taking a value modulus 1 is kind of pointless. The value of a modulus operation is 0 to the modulus - 1. So a modulus of 1 will always yield 0.

Please edit your post, put your code in code tags (to preserve what I'm assuming is excellent indentation), and remove extraneous blank lines.
Last edited on
there is an fmod but I have not ever had a use for it.
are you trying to do some sort of percentage? % is not any kind of percentage operation. Just use math percentages (eg x*.95 is 95% of x) … there isn't any special operator or magic for them in c++.
Topic archived. No new replies allowed.