2 2 votes #include <stdio.h> int main(void) { double a=30; int r: r=a%5; printf("\n r=%d",r) return 0; } Why this code is throwing compilation error ? Programming in C programming-in-c + – junaid ahmad 1.5k views answer comment Share Follow Print See all 9 Comments 9 9 Comments reply Anu007 commented Nov 29, 2017 reply Follow flag what is value of n. 0 0 replyShare Ashwin Kulkarni commented Nov 29, 2017 reply Follow flag r = n%5; undefined symbol n. 0 0 replyShare junaid ahmad commented Nov 29, 2017 reply Follow flag That was a typo :D 0 0 replyShare just_bhavana commented Nov 29, 2017 reply Follow flag @Anu007 it isn't because of type mismatch, it's because modulus operator doesn't work on floats and doubles 0 0 replyShare Anu007 commented Nov 29, 2017 reply Follow flag any refference for such properties .BDW thanks 0 0 replyShare joshi_nitish commented Nov 30, 2017 reply Follow flag there is no semicolon(;) after printf and int r its syntax error. 0 0 replyShare joshi_nitish commented Nov 30, 2017 reply Follow flag also it will give symantic error, because modulus(%) can only be used with integral values. 0 0 replyShare Anu007 commented Nov 30, 2017 reply Follow flag nitish any refference for such property like mod used with int only... 0 0 replyShare just_bhavana commented Nov 30, 2017 reply Follow flag @Anu Refer this http://www.geeksforgeeks.org/can-use-operator-floating-point-numbers/ 2 2 replyShare Please log in or register to add a comment.
0 0 votes %(modulo) operator isn't work with floats and double. Reference Abhisek Tiwari 4 answered Nov 29, 2017 • edited Mar 15, 2019 by Abhisek Tiwari 4 Abhisek Tiwari 4 comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes modulus operation cannot be performed on double. saipriyab answered Nov 29, 2017 saipriyab comment Share Follow 0 reply Please log in or register to add a comment.