Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ASSIGNMENTS AND AS x C Chegg study l Guided so x https://blackboard.hallmarkuniv

ID: 3857471 • Letter: A

Question

ASSIGNMENTS AND AS x C Chegg study l Guided so x https://blackboard.hallmarkuniversity.edu Secure webapps/blackboard content/listCon sp?course id -10084 18 content id 227785 11 UNIVERSITY Hallmark University Courses Week 4 ASSIGNMENTS AND ASSESSMENTS ASSIGNMENTS AND ASSESSMENTS CIST1320-OL-170224 1A (Introduction to Programming C++) Exercise 4.1 Home Page Exercise 4.1.1. Use the for statement in a program that prints all the numbers from n to n2, where n1 and n2 are two numbers specified by the user. (Hint: You'll need to prompt for the two values: then, inside e for statement, initialize i to n and use n2 in the loop conditio Course Overview Course Introduction Exercise 4.1.2. Rewrite the example so that it prints all the numbers from n to 1 in reverse order. For example, the user enters 5, and the program prints 54 32 1. (Hint In the for loop, initialize i to n, use the condition i 1, and subtract 1 from n the increment step. Exercise 4.1.3. Write a program that prints all numbers from 1 to n, but prints only even numbers or only odd numbers. Each number printed will be 2 higher than the last. My Instructor Upload your program to this exercise. COURSE WORK Exercise 4.2 Week 0 Example 4.2.1. Revise Example 4.2 to make it more optimal. When you consider the speed of today's microprocessors, it's unlikely you'll see a difference in execution, although if you attempt to test an extremely large number, say, more than a billion, you might see a difference. (By he way, good luck in finding a prime number in that range Week if you're just looking for one by chance. Prime numbers become rarer as you get into larger values n any case, the following changes to code make the program more Week 2 efficient for large numbers: Calculate the square root of n only once by declaring a variable square root of n and determining its value before entering the for loop. This variable should be a double variable. Once a divisor of n is found, you don't need to look for any more divisors. Therefore, in the if statement inside the loop, add a break Week 3 statement (breaking out of the loop) after setting is prime to false Week 4 Upload your program to this exercise. Week 5 Week 6 Week 7 Week 8 news article related to the new and innovative trends in programming from the following website: s: Wis TOOLS & RESOURCES Please discuss your findings and type a minimum 1200 words essay in MLA format. Discussions 06 AM Ask me anything 3/13/2017

Explanation / Answer

4.1.1

#include <stdio.h>

int main(void) {
   // your code goes here
   int m,n,i;
   printf("Enter value of m and n:-");
   scanf("%d%d",&m,&n);
   for(i=m;i<n;i++)
   {
   printf("%d ",i);
   }
   return 0;
}

Output:- 10 15

11

12

13

14

15

4.1.2

#include <stdio.h>

int main(void) {
   // your code goes here
   int n,i;
   printf("Enter value of n:-");
   scanf("%d",&n);
   printf(" Values in reverse order is:-");
   for(i=n;i>=1;i--)
   {
   printf("%d ",i);
   }
   return 0;
}

Output:- Enter value of n:- 5

Values in reverse order is:-5

4

3

2

1

4.1.3

#include <stdio.h>

int main(void) {
   // your code goes here
   int n,i;
   printf("Enter value of n:-");
   scanf("%d",&n);
   printf(" Even numbers are:-");
   for(i=1;i<=n;i++)
   {
   if(i%2==0)
   {
   printf("%d ",i);
   }
   }
   return 0;
}

Output:- Enter value of n:-10
Even numbers are:-2
4
6
8
10