1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
podryga [215]
4 years ago
7

Create a script that will find the sum of the all multiples of 3 between 1 and 1000 by using For Loop. (Pseudo Code required) 3.

Redo Problem 2 with While Loop and Do While Loop (Use Break at least once). (Pseudo Code required)

Computers and Technology
1 answer:
xxTIMURxx [149]4 years ago
8 0

Answer:

The code is given in the explanation while  the screenshots of the output are attached along. The basic steps of the pseudo code are as follows.

  1. Initialized the variables (counter and summation)
  2. Initialize the loop(for, while, do while)
  3. Estimate the remainder of value with 3 and if the value is 0, this indicates the value is a multiple of 3 so add it to the sum
  4. Re-iterate this until the value is greater than 1000.
  5. Print the results.

Explanation:

The code is given as below

<em>With For Loop</em>

#include<stdio.h> //The library is added

int main(){ //the main function is initialized

  int sum=0,i; //The variables are initialized

  for(i=1;i<=1000;i++){   //The for loop is initiated with iterations from 1 to 1000                  

                                   //with and increment of 1

      if(i%3==0)          //Remainder of i by 3 is calculated to identify multiples of 3

          sum=sum+i; //summation is done

  }

  printf("Using for loop : ");//results are displayed

  printf("Sum is %d.\n",sum);

<em>With While Loop</em>

  i=1; //counter variable is initialized

  sum=0; //summation variable is initialized

  //infinite loop which breaks only when i becomes >1000

  while(i){

      if(i>1000) //condition which breaks only when i becomes >1000

          break;

      if(i%3==0)//Remainder of i by 3 is calculated to identify multiples of 3

          sum=sum+i; //summation is done

      i++;//counter is incremented

  }

  printf("Using while loop : ");//results are displayed

  printf("Sum is %d.\n",sum);//results are displayed

<em>With Do While Loop</em>

  i=1;//counter variable is initialized

  sum=0;//summation variable is initialized

  do{

      if(i>1000) //condition which breaks only when i becomes >1000

          break;

      if(i%3==0)//Remainder of i by 3 is calculated to identify multiples of 3

          sum=sum+i;//summation is done

      i++;//counter is incremented

  }while(i);

  printf("Using do-while loop : ");//results are displayed

  printf("Sum is %d.\n",sum);

  return 0;

}

You might be interested in
Complete the sentence.
Galina-37 [17]
The answer is number 2 accessible
5 0
3 years ago
Which of the following STEM discoverers developed a new type of computer hardware?
PSYCHO15rus [73]

Which of the following STEM discoverers is known for creating complex computational physics to develop computer models to simulate fluid movement?

Edison

Fedkiw

Gates

Hawking

Answer:

Fedkiw

Explanation:

Ronald Fedkiw is a professor at Stanford and also a STEM discoverer that is credited with developing a new type of computer hardware model which was used to simulate fluid movements.

His invention has helped him win various awards because it has helped professionals and technicians create visual effects for videos.

7 0
4 years ago
Given a normally distributed data set of 500 observations measuring tree heights in a forest,
bearhunter [10]

Answer:

Since we have the normally distributed data set of the 500 observations. hence, according to the formula there will be 95% of the total observation within two standard deviations from the mean.

Hence, no. of observations will be= 95% of 500= 95 *5 = 475

Also remember standard deviation is (Xi-X')²

The standard deviation is the measurement of the dispersion of the data set from the mean. And its quite important in Data science.

Explanation:

The answer is self explanatory.

3 0
3 years ago
Determine the distance between point (x1, y1) and point (x2, y2), and assign the result to points Distance. The calculation is:
Nadusha1986 [10]

<u>Question:</u>

Snapshot of the question has been attached to this response.

<u>Answer:</u>

<u></u>

import java.util.Scanner;

import java.lang.Math;

public class CoordinateGeometry{

    public static void main(String []args){

       double x1 = 1.0;

       double y1 = 2.0;

       double x2 = 1.0;

       double y2 = 5.0;

       double pointsDistance = 0.0;

       

       //Declare a variable to hold the result of (x2 - x1)²

       double x;

       

       //Solve (x2 - x1)^2 and store result in the variable x

       x = Math.pow(x2 - x1, 2);

       

       //Declare a variable to hold the result of (y2 - y1)²

       double y;

       

       //Solve (y2 - y1)^2 and store result in the variable y

       y = Math.pow(y2 - y1, 2);

       

       //Now pointsDistance = SquareRootOf(x + y)

       pointsDistance = Math.sqrt(x + y);

       

       System.out.println("Points distance: ");

       System.out.println(pointsDistance);

       

       return;

    }

}

<u>Sample Output:</u>

Points distance:  

3.0

<u>Explanation:</u>

The above code has been written in Java and it contains comments explaining important lines of the code. Please go through the comments.

The snapshots of the program and a sample output have been attached to this response.

4 0
4 years ago
Computer operates nearly 100% accurately but why is the phrase'garbage in garbage out'(GIGO) associated with their use?Describe
k0ka [10]

Answer:

A program gives inaccurate results due to inaccurate data provided because a computer will always attempt to process data given to it. Said another way, the output quality of a system usually can't be any better than than the quality of inputs.

Explanation:

Techopedia Explains Garbage In, Garbage Out (GIGO)

<h3>Mark me a brainlist</h3>
8 0
3 years ago
Other questions:
  • Is microsoft word the same as microsoft office?
    12·2 answers
  • Which of the given original work is protected by the copyright law
    14·2 answers
  • What e-reader technology males a screen that is easy to read and extends battery life
    6·1 answer
  • If you find yourself in a position where you need to restore an object or container within active directory that has been inadve
    6·1 answer
  • PowerPoint Presentation on What type of device will she use to display her presentation and explain it to the rest of the childr
    13·2 answers
  • Your grandmother was an established artist and left you several original paintings after she died. Which of these statements is
    11·1 answer
  • What is the function of control unit? in computer. <br>​
    8·1 answer
  • In the ____ letter style, all components of the letter begin flush with the left margin.
    5·1 answer
  • PLEASE GET THIS CORRECT I AM TIMED. CORRECT ANSWER GETS BRAINLIEST
    10·2 answers
  • Which type of variable has a text value
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!