Question

In: Computer Science

For the following questions, you can use any structure you have learned until now (While/Do-While/ for...

For the following questions, you can use any structure you have learned until now (While/Do-While/ for loops, if-statement, switch-case statement).

Question2: Find all prime numbers between 10 to 100.

hint: a prime number is a number that is divisible by 1 and itself. for example 3, 5, 7, 11, 13 are prime numbers because they are only divisible by 1 and themselves.

Solutions

Expert Solution

Since you have not mentioned which program to use I'm using C program -

Here we will use two loops 1st loop that will cycle from 10 to 100

Other loop will check for eligibility of prime for each number that the first loop cycles through

Here is the program -

#include <stdio.h>
 
int main()
{
  int i, Number, count; 
  
  printf(" Prime Number from 10 to 100 are: \n"); 
  //loop used to check from 10 to 100 for prime
  for(Number = 10; Number <= 100; Number++)
  {
    count = 0;
    //loop to check for prime
    for (i = 2; i <= Number/2; i++)
    {
        if(Number%i == 0)
        {
          count++;
          break;
        }
    }// loop for prime ends here
    if(count == 0 && Number != 1 )
    {
        printf(" %d ", Number);
    }  
  } //loop to check 10 to 100 ends here
  return 0;
}

Output -

Thanks


Related Solutions

Now that you have learned about the Keynesian perspective, what do you think about it? In...
Now that you have learned about the Keynesian perspective, what do you think about it? In your post, be sure to describe they Keynesian viewpoint and how they would use both fiscal and monetary policy to achieve their goals. Do you think Keyes was right? Why or why not?
Now that you have learned how to respond to different types of emergencies, how do you...
Now that you have learned how to respond to different types of emergencies, how do you think you would react in an emergency situation? Explain your answer
Step 1: Read the following questions, and use what you have learned about how the economy...
Step 1: Read the following questions, and use what you have learned about how the economy might impact your business industry, and to summarize your responses in 5 full pages. Consider the concepts and questions below when assessing the economy and the impact it may pose on your business: Describe your ideal capitalist economy. Will these conditions maximize your sustainability and profitability? What indicators would you use to measure goods and services? What happens when the quantity demand is impacted?...
Step 1: Read the following questions, and use what you have learned about how the economy...
Step 1: Read the following questions, and use what you have learned about how the economy might impact your business industry, and to summarize your responses in 5 full pages. Consider the concepts and questions below when assessing the economy and the impact it may pose on your business: Describe your ideal capitalist economy. Will these conditions maximize your sustainability and profitability? What indicators would you use to measure goods and services? What happens when the quantity demand is impacted?...
Now that you have learned a bit about how Amazon uses A/B tests, what do you...
Now that you have learned a bit about how Amazon uses A/B tests, what do you think are some of the risks and challenges associated with performing so many hypothesis tests? What would you do to mitigate those risks? Think about the results of the tests. What were the effects? Look at the size of the effects. Were they small or large? Why were the sample sizes so large?
do you guys have any topic or case can use concepts of behavioral economics to solve...
do you guys have any topic or case can use concepts of behavioral economics to solve real-world problems and shed light on the underlying psychological mechanisms that are responsible for these problems.
5 things you learned in the economic class from only, that you can now or will...
5 things you learned in the economic class from only, that you can now or will be able to apply to your career, your current career or in your personal life.
You have now read and learned about fiscal policy and the impact that it may have...
You have now read and learned about fiscal policy and the impact that it may have on our debt. With everything you have learned thus far, do you believe that fiscal policy is a good thing for the economy? In what ways may it be bad and/or good for the economy? If you could choose between Keynsian Fiscal Policy or letting the economy self-correct what would you choose?
Answer the following three questions. You can use any reference to write your answers (e.g., textbook,...
Answer the following three questions. You can use any reference to write your answers (e.g., textbook, articles, internet web pages, etc.). However, you have to use your own words. No Cheating. No plagiarism. 1. Your boss told you that he wants to put you on charge of the opening ceremony for company new plant in Jeddah. He gives you the authority to choose your team members and to make all necessary decisions. The ceremony will be held on October 30th....
Answer the following three questions. You can use any reference to write your answers (e.g., textbook,...
Answer the following three questions. You can use any reference to write your answers (e.g., textbook, articles, internet web pages, etc. 1. Your boss told you that he wants to put you on charge of the opening ceremony for company new plant in Jeddah. He gives you the authority to choose your team members and to make all necessary decisions. The ceremony will be held on October 30th. Explain in details how are you going to manage your team throughout...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT