From c16791b0aa01075fb4b73fe31afa97e77d33708b Mon Sep 17 00:00:00 2001 From: Sajal193 <74758269+Sajal193@users.noreply.github.com> Date: Mon, 21 Jun 2021 13:51:57 +0530 Subject: [PATCH] Thank You @Sastava007. I'm adding this code just for review purpose and to help newcomers develope interest in programming --- PRIME1.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 PRIME1.cpp diff --git a/PRIME1.cpp b/PRIME1.cpp new file mode 100644 index 0000000..98e80f4 --- /dev/null +++ b/PRIME1.cpp @@ -0,0 +1,37 @@ +#include +#include +using namespace std; +/*This code is contributed by Sajal193. This is a basic level code that gives a +newbie a basic idea of implementation of nested loops and flow commands. ENJOY */ +int main(){ + int t; + cin>>t;//for test cases + while(t--) + { + int m,n; //initializing two variables + cin>>m>>n;bool r; // using bool so as to check condition whether the second + //(nested) loop is executed or not. + + for (int i =m; i<=n; i++) + { + if (i == 1 || i ==0) // if i equals 1 then skip to next increment + { + continue; + } + r = true; + for (int j =2; j<=sqrt(i); j++)//condition loop for checking prime number + { if (i%j == 0) + { r = false; + break; + } + } + + if ( r == true) // To check whether nested loop is traversed or not + { + cout<