Read an integer variable and print all of its divisors (including 1 and the number itself).
Click here to read the complete problem statement.
If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.
#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.