- 5

Let the sequence of numbers, which ends 0

Write a program that counts the amount of sequence numbers, numbers which are prime numbers. use cycle do..while. without arrays.

5th Jan 2017, 9:54 AM
Alex Silin
Alex Silin - avatar
1 Odpowiedź
+ 2
Well you cannot make this code for a sequence of numbers without making use of arrays but you can still check weather a number is prime or not int main () { int a,b=2; cin>>a; do{ if(a/b==0){ cout<<"it is not prime "; break; } else{ continue; } ++b; }while(b<a) return 0; } THE CODE WORKS IN SIMPLE WAY IT DIVIDES ALL THE NUMBER BEFORE THE INPUT NUMBER TO CHECK IF IT IS DIVIDED BY ANY AND IF NOT IT IS PRIME point* if it is prime nothing will be displayed #SiD
7th Jan 2017, 5:46 AM
Siddharth Naithani
Siddharth Naithani - avatar