0

Set the boolean variable p to true if the integer n (n > 1) is a prime number, and false otherwise.

19th Apr 2021, 5:58 PM
Nikita Volkov
Nikita Volkov - avatar
3 Answers
+ 3
Please show your attempt and where you got stuck. No one here will do your homework for you
19th Apr 2021, 5:59 PM
怌ļ¼Øļ¼”ļ¼°ļ¼°ļ¼¹ ļ¼“ļ¼Æ ļ¼Øļ¼„ļ¼¬ļ¼°ć€
怌ļ¼Øļ¼”ļ¼°ļ¼°ļ¼¹ ļ¼“ļ¼Æ ļ¼Øļ¼„ļ¼¬ļ¼°ć€ - avatar
0
Seems to be your homework. Anyways post what you have tried
19th Apr 2021, 6:05 PM
Atul [Inactive]
0
I want to add a while loop here. #include "locale.h" #include <iostream> #include <stdio.h> #include <conio.h> #include <tchar.h> #include <string> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { setlocale(LC_ALL, "Russian"); int n; cout << "Š’Š²ŠµŠ“ŠøтŠµ цŠµŠ»Š¾Šµ чŠøсŠ»Š¾ n " << endl; printf("n = "); scanf_s("%d", &n); bool p = true; for (int i = 2; i < n; i++) { if (n % i == 0) { p = false; break; } } if (p) printf("%d - false ", n); else printf("%d - true ", n); _getch(); return 0; }
20th Apr 2021, 7:51 PM
Nikita Volkov
Nikita Volkov - avatar