Share

 

RAAJRANI.COM


Q & A Home
Math
Science
History
IT & Web
Programming
Health
Business
Arts & Humanities
Social Studies
Engineering & Technology
Arts & Entertainment
Humanities
Sports
Auto
Hobbies
Books and Literature
Electronics
Food & Drink
Jobs & Education
Law & Government
Travel & Places
People & Society
Beauty & Health
Animals & Plants
Other


Obaidul Haque    30 Jun, 2024 12:00:46 AM    1    221


Best Answer: Write a program using two nested for loops.

The first for loop is used to loop between the numbers provided by the user. For example, 2 to 10.
A variable flag is set to 0.
The second for loop is used to loop between 2 to the number that is stored in i.
Inside the second loop, the value of i is divided by each number from 2 to a value one less than i (i – 1).
While dividing, if any number remainder results in 0, that number is not a prime number. So the variable flag is set to 1.
Finally, all the numbers that have a flag 0 (not divisible by other numbers) are printed.

Obaidul Haque    30 Jun, 2024 12:00:46 AM

All Subjects


Math

Science

History

IT & Web

Programming

Health

Business

Arts & Humanities

Social Studies

Engineering & Technology

Arts & Entertainment

Humanities

Sports

Auto

Hobbies

Books and Literature

Electronics

Food & Drink

Jobs & Education

Law & Government

Travel & Places

People & Society

Beauty & Health

Animals & Plants

Other




About     Privacy     Terms     Contact

Copyright 2018 - 2026 Raajrani. All Rights Reserved || Powered by: RAAJRANI Technologies