0 like 0 dislike
6.6k views

Write a program that get the input of two integers n and m(n < m). Find out all prime numbers between n and m (not include n and m), then display them on the screen.

寫一個程式 輸入兩個整數n和m (n < m),找出所有n到m之間的質數(不包含n和m)。

Example input 1

1 10

Example output 1

2 3 5 7

 

Example input 2

10 20

Example output 2

11 13 17 19

 

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

22 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
    int a,b,j,i,c=0;

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

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

    }

    else{
** **** ***** * * * ** *** ** ** * * * **** * %d",j);}
** * * * * ***** 0;
}
answered by (-167 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,b,c,d,e,i,o;
* ** * * * * * ***** ** ** * %d",&a,&b);
****** * * ** * * *** * *
** * * * **** * * * ***** ** * * * * * ** * *** **
* *** *** *** * * ** **** * * *** ** ** * *** *
* ** * * * * * ***** * *** * * *** ***
    }
****** ** * * *** * * * * ** * * ** **
* ** * * * * * *** * * *** *** ** * * ** ** ** * *
*** * * ***** * ** *** **** ** * **** * * *** * ** **** * **** *
** * * *** **** * ** * * * * * * ** * * ** * ** **** ** ** * * ** * ** ** * *
**** ***** ***** * *** * * ** ** * * ** * *** ** * ** ** * ** ** * ** * * * * **

** ** ** ** ** ** * * * * * ** * *** ** * ** * * * *** ** *** *
* ** ***** **** * ***** * ** * *** * * **
    }




}
answered by (-32 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
prog.c: In function 'main':
prog.c:15:16: error: expected ';' before 'break'
                break;
                ^~~~~
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
    int n1, n2, i, c=0;
    scanf("%d %d",&n1,&n2);
    for(i=n1+1;i<n2;i++)
    {
******* * ******** * * * * *** * *** ** a;
****** * * * ******* * * * * * ** **** **** *** * * * ***
*** *** * * ** * ** * * * ** ** *** *******
*** * * *** ******* * ** ** ** *** * **** * *
*** ** * ** **** * ** ******** ** ** ** * * * ******* *** *
        }
* * * **** ** ** ** * * * * ** ** * ** ** * * * *
** * ** * *** * ** * ** **** *** ***** * * * ** ** * ** * * ** * ** * *
** **** * *** * * ** * ** * * ** * * * ** *** ** **** * **** * * ** * ** * ** * ** * *
*** * ****** * * ** ** * ** *** * ** * * * * * ** * * * *** ** *** * * * ***
** * * * **** * * ** **** * * ****** * * ******* **** * **** ** ***** ** * * * * *********** **** *** * * *** * * ** * ** * * *** ** i);
******* *** ******** ***** ** ** * * ***** * *** * * * * * ** * * * * **** ** *** * **** * ** ** ****
* *** ******* * ** ** *** * ** * **** * *** **** * * * * * * * ***** *** ** * ******
*** * * ** * * * * * * ** ** ****** ** * * ** * * *** **** * * * * ** * **
*** * * * * ** *** * * *** * ** **** * ** * *** * * **** **** * ***** ** ** ** **** * * ** %d", i);}
*** * *** * * * *** ** * * * ** *** ** * **** * * ** * * * * * * *** *** ******* *
    }

    return 0;
}
answered by (-233 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,b,i,j,k,c=0;
scanf("%d %d",&a,&b);
for(i=(a+1);i<b;i++)
{
* * * *** * * ** *** * * ** *** * *
    {
* * ** * ** *** * * * * ** ****** ** * *
*** * *** ** *** * ***** * ** ** *** ** * * **
** ***** ****** ** * * * * *** ** * *
** * ** *** * * ****** * * *** ** * * **** * ** ***** * * ** ** *
* *** ** * ** * * ** * ** ** * ***** **** * **** *** *
**** **** ****** * * ** * * ** * * ** **** * ** * ** ** *** ** **** * * * **** ** *** *** * * ****** **** ***
* *** * * ** ** ** * * * * *** * *** ** * * * ** **** *** * * * * * *** ***** * ****
* * * ** ** ** * *** *** * * * * *** ** ** * * * *** ** * * * ** * * ** ** *
** ***** *** *** * * * * * *** * * ** *** * * **** * *** * * * * *
* * * * ** ** *** ** * *** * *** * * ** **
*** *** ***** *** ** **** **** * * **** * *
**** * * ** * ** * * * ** * * ***** *** ** * ** * * *** ** %d",i);
** * * **** ** * *** **** *** ** * ***** ** *
    }
if(k==0)
{break;}

    }
}
return 0;
}
answered by (-32 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(void)

{
   int num1,num2,x,flag=0,count=0;


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

   while (x=2; x=num1-1;++x){
**** * *** * ** **** * * * * * ** * **** *
*** * * * * ***** ** * **** *** * * ***

* * * *** * * *** ** * (x==num1/2){

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

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

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


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

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

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










   }



return 0;

}
answered by (-107 points)
0 0
prog.c: In function 'main':
prog.c:12:14: error: expected ')' before ';' token
    while (x=2; x=num1-1;++x){
              ^
prog.c:16:19: error: expected ';' before ')' token
     for (x==num1/2){
                   ^
prog.c:16:19: error: expected expression before ')' token
prog.c:23:24: error: expected ')' before 'num1'
             printf("%d"num1);
                        ^~~~
prog.c:23:22: warning: format '%d' expects a matching 'int' argument [-Wformat=]
             printf("%d"num1);
                      ^
prog.c:33:5: error: expected ';' before '}' token
     }
     ^
0 like 0 dislike
Hidden content!
#include<stdio.h>
int num_is_prime(int x)
{
** *** * * ** *** ** y;
** *** * * * * * ** * ****** * **
    {
* * ** ** * *** *** ** ** ** *** **********
** * *** * **** * ** **** ** ** *** * *** **
** **** * ** ** * *** ***** * * * ** *** ** * ** *** * * **
    }
* ** * * * ** ** **** **
    {
* ** * **** * ** *** *** ** **** *** * ** * ** * 1;
    }
* *** ** * * * * * ** *
    {
* * ****** ** **** ** * *** * ***** ** **** ******** 0;
    }
}
int main()
{
** * *** ** ** ** ** **** a,b,f=1;
* **** * ** **** * * * * * * %d",&a,&b);
** *** ** * ** *** * * ** * * * ** **
** ****** * ***
* *** * ** ***** * * * * ** * * * * **** **** *****
** * ** * ** **** * * ** * ** * **** ****** * *** * **** * **
** * * ******** ** * **** * * ***
** **** *** * ** ** * ** ** ** * * ****** ** ** ** ** * * ** **** * ** ***
* ** * * ** ** * * * **** *** *** *** ** ** ** ** ** ** *** * *** ***
** * *** ******** * * * ** ** * ** ** * ** * * ** ** ** * * **** ***** ** * * * * ** * * * ");
** ** ** * *** ** * * *** ***** * ** ***** ** * * * ***** * *
** *** ** * * * ** * ** ***** * * ** * * ** ** * * * ** ** * *** * ** ** ****
* * ** * ** * * * * *** * **** * * * **
** * * * * *** * * *** * * * *
    }
}
answered by (-255 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 * * ** * * *
int main (){
int a,b ;
int i,n,num[12];
* ** * ** a\n");
* **** *** * **
num[0]=0;
num[1]=1;
* * **** *** ** * * **
* **** ** * * ** **
** * *****

** * * *** ** **** * ** **** * **
** ***** * *** * ** ** * *** **** ** ** * ** ** **** * *
****** **** * * * * ** * * * * * *** * * * * * * *** *
** * ** * ** * * * *
}
return 0;
}
answered
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 * * ** ****
int main (){
int a,b ;
int i,n,num[12];
** ** ** a\n");
* * * * ** ** *** ****
num[0]=0;
num[1]=1;
** * * * * ** ***
*** * *** ** * ** ** *
* *** **

* *** ** * * * ***** * * ** *
* ** ** * * *** *** ** ***** * * * * *** * * **** *
*** * ************ * * ***** ***** ** * **** * * * **** *** *** ****** **
* * * * * * **** * * **
}
return 0;
}
answered
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 ***** *** **
int main (){
int a,b ;
int i,n,num[12];
*** * a\n");
** * ****** * * * **
num[0]=0;
num[1]=1;
* * * ** ** ****
**** ** * * ***** * ** * *
** ** **

** ** * * * * ** ** *** *** **
** **** ** *** *** * *** * * ***** * *** ** ** ***** * * * *
* * * * * ** ** * **** * * *** * * * * * *** * **** ***
* * ** ****** ** * *
}
return 0;
}
answered
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()
{
    int n,m;
    int i;
    int prime;
    int flag;
    int count=1;


    scanf("%d%d",&n,&m);

    if(n<m)
    {
        for(n=n+1;n<m;n++)
        {
**** * * * * * * **** * ** ** * * * ***** *** ** * * ** ** *** * ** * *
* *** ***** * * * * *** *** ** ** ** **** ** *** * * * * *** *** ****
* *** ****** * ******* ** *** * **** *** **** ****** ** **** * ** ** ***** * ** * * * * * *

*** * * *** ** ** * **** ** ** ** ***** * * * * *** *** * ** ** ** ** ********* ** * ***** * **
* ******* ** ** **** ** ***** ***** * * **** * * * **** * * * *** **** ******* **
* *** * * ** *** ** *** * ** *** *** **** ** ** * * *** ** *** ** *** * ** *** **** * ** ** * * ** * * *** *** * ** * *
* ** ****** *** ** ** *** * * * ** * * * * ** **** ** * ** * * ** ** * * * * * ** *** **** ******** *
*** ******* ** **** **** **** ** * * * * **** * ** *** ** **** ** ** **** *** **** * ** * * * ** * ***** * * ** * ** ** **** * * * * *
* ****** ** * * * *** ** * ***** *** * *** * ** *** ***** ***** *** * * ** * ** * * * ** *** ** ** * *** * ** ** * * ** * *** ** ** *
* * **** * *** * ***** ** **** * * * * * **** **** * * * ****** ** *** ** ** * *** ** ** * ***** ** ** * * * * ** ** ****
* * ***** **** ** ** **** ***** * ***** **** *** * * * * * *** * ** * * ** *** * ** * *** **
* * ** * ** * ** * * * * *** * * * *** * ***** * * * * ******** * ** * *** *** * ** * **** * * * ** ** ****** * * *
* * *** ** **** *** * *** ** * ** * ***** * * *** * * ** ** **** * * ** * * ** ********* *** ** * ** * * ** * *** **** *** * * ** *** %d",n);
** * ** *** * * * *** * * * ** *** ** *** * **** **** ** * * * *** ** **** *** *** * * **** * ** * **** * * *** *
* ** ** * * **** ** ** *** * ** * *** * ***** * * * * * ** ** ** **** ** ** * * *** *** * * ** * ** **

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

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

* ** * *** ** ** * *** ** ** ** ** ** ***** ** * * *** * ***** * ** * * *
        }
    }



    return 0;
}
answered by (-193 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.243.62
©2016-2026

Related questions

1 like 1 dislike
45 answers
[Exam] asked Nov 15, 2017 in Midterm by thopd (12.1k points)
ID: 32708 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 11.4k views
0 like 0 dislike
21 answers
[Exam] asked Dec 9, 2017 in Midterm by thopd (12.1k points)
ID: 36754 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 6.3k views
0 like 0 dislike
10 answers
[Exam] asked Dec 9, 2017 in Midterm by thopd (12.1k points)
ID: 36752 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 3.8k views
0 like 0 dislike
99 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in Chapter 6: Loops by semicolon (5.2k points)
ID: 29829 - Available when: 2017-11-02 18:00 - Due to: Unlimited
| 23.9k views
12,783 questions
183,442 answers
172,219 comments
4,824 users