+ 1

Using Do While Loop,

Using do while loop Find and display all prime numbers in a collection of N numbers in the function Prime_Nos. Get the value of N before scanning each value in the collection of N numbers in the main program. All prime numbers should be displayed on the same line but separated by two spaces. The value of N must be a positive number.

28th Nov 2023, 3:01 PM
Riymon
8 ответов
0
hello world
30th Nov 2023, 11:27 AM
Laguras Xyreel Castromero
+ 2
The code what you made I done worked. Now you can continue. https://sololearn.com/compiler-playground/ckOJrj7s41SF/?ref=app
30th Nov 2023, 8:44 AM
JaScript
+ 1
First will be needed your attempt better link to code on playground.
28th Nov 2023, 6:08 PM
JaScript
+ 1
I see. But if you want learn to code try to solve that first. After your new try can be again helped.
30th Nov 2023, 10:35 AM
JaScript
0
The output should be like this 2 3 5
30th Nov 2023, 2:17 AM
Riymon
0
#include<stdio.h> int Prime_Nos(int N); int main() { int N, num, ctr; printf("\n\tEnter N num: "); scanf("%d", &N); Prime_Nos(N); printf("\n\n\n"); return 0; } int Prime_Nos(int N){ int ctr = 0, prm_count= 0, divisor, is_prime, num; do { printf("\n\tEnter a number: "); scanf("%d", & num); if(num > 1){ is_prime = 1; divisor = 2; while (divisor < num) { if (num % divisor == 0) { is_prime = 0; break; } divisor++; } if (is_prime) { if(prm_count > 0){ printf(" ");}
30th Nov 2023, 2:18 AM
Riymon
0
printf ("%d", num); prm_count++; } } ctr++; } while (ctr < N); //printf ("%d", prm_count); }
30th Nov 2023, 2:18 AM
Riymon
0
Thanks bro but output isn't answer the problem asked, the output should be displayed same line but separated two spaces
30th Nov 2023, 8:52 AM
Riymon
Актуальное сегодня
API