This is a companion discussion topic for the original entry at https://toph.co/p/divisors
This is a companion discussion topic for the original entry at https://toph.co/p/divisors
#include <stdio.h>
int main() {
int A,i,X;
scanf("%d",&A);
for(i=1;i=A;i++){
X=A%i;
if(X==0){
printf("%d\n",&i);
}
}
return 0;
}
how can I make this efficient??
#include<stdio.h>
int main() {
int A,i,X;
scanf("%d",&A);
for(i=1;i<=A;i++){
X=A%i;
if(X==0)
printf("%d\n",i);
}
return 0;
}
for loop condition should be i<=A,i=A means i assigned by the value of A,for loop conditional expression should be an operator.
printf variable shouldn’t be addressed using &, in that statement it prints the memory address of i.
anyway thanks for the unnecessary suggestionsuggestion
Well I’m a beginner level and haven’t much experienced yet.So I thincked that way.
#include <stdio.h>
int main() {
int n,i;
scanf("%d",&n);
for(i=1;i<=n;i++){
if(n % i == 0){
printf("%d",i);
}
}
return 0;
}
Whats the problem in this code?
you try another digites like 5 or 4 , 7 and then you will see your code not working properly
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
for(int i=n;i<=n;i–){
int a=n/i;
if(n%i==0){
printf("%d\n",a);
}
}
return 0;
}
what is wrong with this code??
it shows runtime error
#include <stdio.h>
int main() {
int i, A;
printf(“Enter the value of n: “);
scanf(”%d”, &A);
if(A < 100){
for(i = 1; i <= A; i++){
if(A % i == 0){
printf(“%d \n”, i);
}
}
}
return 0;
}
it solution why don’t accept