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
Student Generated Code Assignments Option 1: Write a program that will read in 3 grades from the keyboard and will print the ave
AlladinOne [14]

In python:

first_grade = float(input("Please input the first grade "))

second_grade = float(input("Please input the second grade "))

third_grade = float(input("Please input the third grade "))

print("The average of the three grades is {}".format( round((first_grade + second_grade + third_grade) / 3,2)))

5 0
3 years ago
Why is it that even though there aren't the max number of answers on a question, (or sometimes even NO answers) When I click the
maks197457 [2]
It has happened to me before. i think it’s just because someone is already typing an answer maybe ‍♀️ or try restarting the app and get back on it. might be jus a glitch from the app but either way hope you get it fixed :)
4 0
3 years ago
____ that allow individuals to perform specific tasks are launched via the operating system, such as by using the windows start
schepotkina [342]
Programs that allow individuals to perform specific tasks are launched via the operating system, such as by using the windows start menu on windows computers. Programm is a set of instructions written for a computer.<span>The Start menu contains icons for all installed programs and data collections, usually for programs.</span>
3 0
3 years ago
What are three different reasons why people access networks? <br> Give an example of each reason
denpristay [2]

Communication: Communication is one way to be connected to the network and use the internet. It helps maintains communication with other network users. A few examples include email, IM services, video conferencing, Skype and many more.

File sharing: Easily sharing files and data. From businesses to schools to friends, everyone sends files to through internet and this has become an essential part of life. Various services like Gmail and yahoo mail are used.

Social networking: This is an essential medium to communicate with friends and family members. Examples include Facebook, Twitter, and Instagram.






3 0
4 years ago
Whats the size of a short bond paper in microsoft word?
poizon [28]
I believe the size is 8.5x11
7 0
3 years ago
Other questions:
  • What is and effective way to display calculation in a word document?
    5·1 answer
  • Data mining is defined as: a)Separating data and programs such that each can be changed without changing the other b)Allowing ma
    5·1 answer
  • ________ is a mobile broadband technology that relies on microwave transmissions to blanket large metropolitan areas from microw
    11·1 answer
  • Which type of worker would most likely be able to begin work after receiving a high school degree and completing an
    13·1 answer
  • What are two critical properties for a cryptographic hash function?
    9·1 answer
  • This is your code.
    9·1 answer
  • From the pictures below select 5 words that best describes quality and briefly discuss it in not more than 3 sentences
    6·1 answer
  • Commercial technical data and commercial software:_________.
    11·1 answer
  • Can anyone fix this code for me?
    8·1 answer
  • What is the current situation of drone technology in emergency rescue and recovery
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!