0 like 0 dislike

Write a program that asks the user to type an integer N and find out all the factors of N and display it on screen.

寫一個程式 輸入一個整數N,找出N的所有因數

Example input 1

10

Example output 1

1 2 5 10

Example input 2

24

Example output 2

1 2 3 4 6 8 12 24

 

[Exam] asked in Midterm by (11.3k points)
Available when: 2017-11-15 14:10 - Due to: Unlimited
| 323 views

21 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{

   int a,num1,count;
   count=0;

*** * * ** * * ** * * *** * * * * * ***

   for(a=1; a<=num1; a++){


** *** * * * ** ** ** (num1%a==0)
** *** * * *** * ********* *** * * *** **

* * ** *** ***** ** ** * * ** * ** (count==0)
* * ** * ***** * ** * ****** **** ** *** *** ** *****
* ** * * *** ** * *** *** * *** * ** * ***** *** ****** ***** * ** ** * * * **

*** ** *** **** * ** **** * * * ** **** ** *
* ** * *** * ** *** * ***** * * * {

* ** ********* ** * * * ** * * * * ** *** * * * * *** * * * * * * %d",a);
* * ** ** ** * * ** ** * ** *** ** *** * *** * ** ** *** * ** * **
****** **** ****** ** ** ********* * * *** * * * * ** * **** *** ** *** *

* * ** ***** *** *

}


return 0;
}
answered by (-107 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{

   int a,num1,count;

* * ** * * * ** * * * ** **** * *

* **** *** ****** a<=num1; a++){


* **** *** * ** * (num1%a==0){

* ** **** * ** * * * *** *** * * * * ** * **** (count==0){
* *** * *** * * * *** *** *** * ** * *** ****** *** * ******* ***** * *

** * ** ** * ** *** ** * * ** *
* *** ***** ** * ******* * * * * ** * * * {

** ***** ** * * * * * ** * ** **** * * ** * ** ***** %d",a);
******* ****** * ** *** **** * * ** ** * * ** *** * ******* * * * ** ** * *
*** *** * ***** * ** **** *** * *** ****** * * * * * ** * * * * * ****

** **** ** ***** * * **

}


return 0;
}
answered by (-107 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{

   int a,num1,count;

* *** * ** * * * * ** ** *

* ** **** ** *** ****** a<=num1; a++){




* ***** * *** * * * (num1%a==0){

* ** ** * * * **** * *** *** * * * * (count==0){
** ***** ** ** *** **** * * * ** *** * * *** ** *** * *** * * * * * ** * * * *

* * * * * *** * * * * *** * ** *** * *
* **** *** *** ** ****** * * * * * * *** * ** * ** {

********** *** * *** * ** ** ***** ****** ****** ** *** ****** * * *** %d",a);
* * *** * ** ****** **** * * * ** ** **** ** * **** ***** * ** ** **** *
* * * * *** ** * * * ** * * * ** * *** ** * ******** ** *** * * * * * * ****

* * *** * * *

}


return 0;
}
answered by (-107 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{

   int a,num1,GCD,count=1;

** *** * **** ** *** ** ***** * * * ** ** *

**** * * * ***** ** * a<=num1; a++){




** ** * * * * * * * * (num1%a==0){

*** ***** * * * * **** * * **** * * ** * * * * (count==0){
** * * * * * * ***** * * *** * ** * * ** **** * * * ** *** * * ** ** ** ***

*** **** **** * * *** * ** ** ** *** ** *** *
* * * ** ***** *** * ** * ****** * * *** * ** * {

**** ***** ** ** ** * ** * * *** * * ** * *** * ** * * * * *** * * * %d",a);
** * ** * * * *** ** * * ***** * **** * * * * ** ** * * *****
* ******* * *** ** ** * * ** * ** * *** * * * * * ** ***** ****** ** ** **** *

* *** * * * **

}









return 0;
}
answered by (-107 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
    int a;
* ** * * **** *** *** * ** * * *** ** **

    int i;
    int c=0;
*** * **** *** **** * *** * ** *
    {
* * * * ** * *** **** * ** * ** *** * * *********
* * ** **** * **** *** * * ** ******
*** **** ** ** *** * * * *** ** ** ** * * **** ****** ** *** *** * *
******* * * * * *** * ** * * *** * * * ** * ** ** *** * * * * * ***
* *** ***** ** **** **** * * * ** ** *** * * ***** *
* *** * ** * ** ****** ************ ** * * * ***** * * ** * *** *** ** ** * ** ** * ** ********
* ***** ****** *** ** ** *** * *** * * ** ** ** * ** * * ** * ** * *
* ** ** *** * * * * **** ** * * ** * *
** ***** *** **** ** * *** ** * ** ****** ***** *** **** * *
* ** ******** ** ** ** *** * * ** ** **** ** * * * *** * * * * * * ****** * * * * %d",i);
** ** * * *** **** * ** * * ** * *** ****** * *** * *** **

** *** *** *** * * * ** ** * * * * *****
    }
    return 0;
}
answered by (-167 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
    int n,i,c=0;

* ** **** *** ** * * ** *** ** * ***

** ** *** * * * * ** ** * **** *** **

*** *** * **** *** ******* *
*** * ** ** ** ** ****** * * ** ** **** *
** * ** ******** ** * * * *** **** *
* * * ***** *** ** * * * * ** * ****** ****** ******** * * * *** * ** * ** *
*** * * * * ** *** * ** ** *** ** * * * *** * * * * ** * * ***
* * *** ** * *** ** * * * **
** ****** ** * ***** ** * ** * * *** ** * * * *
* * * ** * ** * * ***** * * **** * * * *** **** * *** ** * ** * * ** ******* * * **



    }
return 0;
}
answered by (-167 points)
0 0
prog.c: In function 'main':
prog.c:6:11: warning: too many arguments for format [-Wformat-extra-args]
     scanf("d",n);
           ^~~
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
    int n;
** * * ** * ****** ***** ** ** * *** *

    int i;
    int c=0;
    for(i=1;i<=n;i++)
    {
**** * **** * * * ** ** * * *** **
* * * ** * ** * **** ***** * **
* ***** * * **** * ** * ******** ** **** **
* *** *** ** * * * ** * * * * * ** *** * ** * * * ** ** **
** * ** * ****** ** *** * * * * ********* * * * ** * ***** ** * ** * *
***** * ***** * * **** ** * ** **** ** ** *** * * *** * ** * ** * *** * * * ** ***** * ** * **
* ** ** ** * ******** *** *** * * * * * ****** ***** * * *** *** ** * *
* * * ** * **** * ** ** * **** ** *** ** *** * ***** * * * ***
* ** * ****** * ** * * *** * * ** * ** * *** * * * *
** **** ** **** **** * ** ** * * * * * ** * * * ** ** * *** *** * ****** * * * * %d",i);
** *** ** * * * *** * *** *** * ** ** * ** **** *

** * ** ** * * * ** ** * ** **** ** * *
    }
}
answered by (-249 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main(){
* * **** ** ** ** *** *** * n;
** *** ***** **** * i;

** * ******* * * ***** * ** ** *** ** **

* ** ** **** * * ** * ** *
**** * * * * * * **
* * **** * * ** *** * * ********* * * ** ** == 0)//check if 'i' is a factor of 'n'
* ** * **** * * * * * * **** *** * *** ** * * ",i);
**** **** * **


* * * * ** * * * * ** 0;
}
90/100 answered by (-74 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
**** *** ***** * ** number, i;

** *** * * * * * ** ** * * * **** * **** * ** *

** ** *** * ** * * * ** * i <= number; ++i)
    {
*** ** * * * *** * * * * * ** * * **** ** == 0)
* * * * * *** ** ** ** ** * * **
* * ** ** ** ** ** ** ** ****** * **** *** * *** * * * * * *** ",i);
* * * * * ** * * **** * **** * * * *
* * ** * ** ** ** *
** ** * ** * * * * * * 0;
}
90/100 answered by (-233 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
** *** *** * ***** ** *** number, i;

*** * ** * *** ** * * * ** * ** &number);

** ** * ** * ** * * i <= number; ++i)
*** * ** ** * ** ** **
* ***** ** *** *** * * **** ** **** * * * ******* == 0)
* * * * * ** * ** ***** *** **
*** * **** * ** * * * ** * * ******* *** ** * * ** * * ** * **** ", i);
* ***** * *** * *** ** ** * ** * *
* ** **** ** * ** **
* * ** *** * * ** ** * ** 0;
}
answered by (-233 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.63.21
©2016-2020

Related questions

3 like 0 dislike
47 answers
[Exam] asked Nov 15, 2017 in Midterm by thopd (11.3k points)
Available when: 2017-11-15 14:10 - Due to: Unlimited
| 215 views
0 like 0 dislike
22 answers
[Exam] asked Dec 9, 2017 in Midterm by thopd (11.3k points)
Available when: 2017-11-15 14:10 - Due to: Unlimited
| 327 views
0 like 0 dislike
10 answers
[Exam] asked Dec 9, 2017 in Midterm by thopd (11.3k points)
Available when: 2017-11-15 14:10 - Due to: Unlimited
| 116 views
0 like 0 dislike
72 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in Chapter 6: Loops by semicolon (5.2k points)
Available when: 2017-11-02 18:00 - Due to: Unlimited
| 497 views
9,615 questions
94,666 answers
76,330 comments
2,931 users