Answer to Question #326034 in C++ for Muhammad Usman

Question #326034

for (int i = 1; i <= 100; i++)


{


for (int j = 2; j < i; j++)


{


if (i % j == 0)


{


bcd++;


break;


}


}


if (bcd == 0 && i != 1)


{


cout << i << endl;


}


bcd = 0;


}

1
Expert's answer
2022-04-08T16:06:04-0400
#include<iostream>

using namespace std;

int main()
{
	int bcd = 0;
	for (int i = 1; i <= 100; i++)
	{
		for (int j = 2; j < i; j++)
		{
			if (i % j == 0)
			{
				bcd++;
				break;
			}
		}
		if (bcd == 0 && i != 1)
		{
			cout << i << endl;
		}
		bcd = 0;
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS