C program for number factors - “Floating point exception” error
up vote
0
down vote
favorite
I'm trying to find the factors of the number b
but it's giving me an error Floating point exception
. What's wrong?
#include <stdio.h>
int main(){
int i, b;
scanf("%d", &b);
for (i = 0; i < b; i++){
if (b % i == 0){
printf("%d ", i);
}
}
return 0;
}
c
add a comment |
up vote
0
down vote
favorite
I'm trying to find the factors of the number b
but it's giving me an error Floating point exception
. What's wrong?
#include <stdio.h>
int main(){
int i, b;
scanf("%d", &b);
for (i = 0; i < b; i++){
if (b % i == 0){
printf("%d ", i);
}
}
return 0;
}
c
Ahh, so starting from i = 1. thanks
– TRViS
Nov 11 at 0:29
2
when a user runs the posted code, they are left with a blank screen, with no indication of what they are expected to do. Strongly suggest prompting the user before calling thescanf()
function
– user3629249
Nov 11 at 0:57
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to find the factors of the number b
but it's giving me an error Floating point exception
. What's wrong?
#include <stdio.h>
int main(){
int i, b;
scanf("%d", &b);
for (i = 0; i < b; i++){
if (b % i == 0){
printf("%d ", i);
}
}
return 0;
}
c
I'm trying to find the factors of the number b
but it's giving me an error Floating point exception
. What's wrong?
#include <stdio.h>
int main(){
int i, b;
scanf("%d", &b);
for (i = 0; i < b; i++){
if (b % i == 0){
printf("%d ", i);
}
}
return 0;
}
c
c
edited Nov 11 at 0:29
asked Nov 11 at 0:27
TRViS
12
12
Ahh, so starting from i = 1. thanks
– TRViS
Nov 11 at 0:29
2
when a user runs the posted code, they are left with a blank screen, with no indication of what they are expected to do. Strongly suggest prompting the user before calling thescanf()
function
– user3629249
Nov 11 at 0:57
add a comment |
Ahh, so starting from i = 1. thanks
– TRViS
Nov 11 at 0:29
2
when a user runs the posted code, they are left with a blank screen, with no indication of what they are expected to do. Strongly suggest prompting the user before calling thescanf()
function
– user3629249
Nov 11 at 0:57
Ahh, so starting from i = 1. thanks
– TRViS
Nov 11 at 0:29
Ahh, so starting from i = 1. thanks
– TRViS
Nov 11 at 0:29
2
2
when a user runs the posted code, they are left with a blank screen, with no indication of what they are expected to do. Strongly suggest prompting the user before calling the
scanf()
function– user3629249
Nov 11 at 0:57
when a user runs the posted code, they are left with a blank screen, with no indication of what they are expected to do. Strongly suggest prompting the user before calling the
scanf()
function– user3629249
Nov 11 at 0:57
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244748%2fc-program-for-number-factors-floating-point-exception-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Ahh, so starting from i = 1. thanks
– TRViS
Nov 11 at 0:29
2
when a user runs the posted code, they are left with a blank screen, with no indication of what they are expected to do. Strongly suggest prompting the user before calling the
scanf()
function– user3629249
Nov 11 at 0:57