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
melomori [17]
4 years ago
15

c++ Write a for loop that computes the following sum: 5+10+15+20+...+485+490+495+500. The sum should be placed in a variable sum

that has already been declared and initialized to 0. In addition, there is another variable, num that has also been declared. You must not use any other variables.
Computers and Technology
1 answer:
ElenaW [278]4 years ago
5 0

Answer:

#include <iostream>

#include <cstdlib>

 

using namespace std;

 

int main(){

 

 

   int sum=0, num=5;   //variables declaration and inicialization

 

   while (sum<500){   //conditioning to do the sum up to 500

   sum=sum+num;     //actually sum process

   cout << "The value is: "<<sum;   //show the result in screen

   };

   return 0;

}

You might be interested in
What is the Multiplier if the change in RGDP is $525,000,000 and initial spending is $100,000?
OLEGan [10]
The right answer is A
4 0
4 years ago
Write a function that takes as input a single integer parameter n and computes the nth Fibonacci Sequence number. The Fibonacci
RSB [31]

Answer:

Following are the code to this question:

def Fibonacci(n):#defining a method Fibonacci that accept a parameter

   a = 1#defining a variable a that holds a value 1

   b = 1#defining a variable b that holds a value 1

   if n <= 0:# Use if to check n value

       print("invalid number")#print message

   elif n == 2:#defining elif that check n equal to 2

        return 1#return 1

   else:#defining else block

       print(a)#print value of a

       print(b)#print value of b

       for i in range(2,n):#defining for loop to calculate series

           s = a + b# add value in s variable

           a = b # interchange value

           b = s# hold s value

           print(s)#print s value

Fibonacci(10)#calling method

Output:

1

1

2

3

5

8

13

21

34

55

Explanation:

In the above-given program code, a method "Fibonacci" is defined, which holds a value "n" in its parameter, and inside the method two-variable "a and b" is defined, that holds a value "1".

  • In the next step, if a block is defined that checks n value is less than equal to 0, it will print "invalid number" as a message.
  • In the elif, it checks n value is equal to 2 it will return a value that is 1.
  • In the else block, it will calculate the Fibonacci series and print its value.
4 0
3 years ago
How do you measure the capacity of speed and memory of computer system<br>Explain.​
jeka94
Im sorry i just need points
3 0
3 years ago
A ___________ organizes related commands together, under a tab.
notsponge [240]
A menu bar organizes related commands together, under a tab.
So the answer is <span>b. menu bar</span>
8 0
4 years ago
WILL GIVE BRAINLIEST!!!!!!!
denpristay [2]

Answer:

A drill is one of the most important tools a dentist can have. They run on pneumatic systems which gives the drill power and precision.

Explanation:

So, false

3 0
3 years ago
Read 2 more answers
Other questions:
  • Select the correct answer.
    8·2 answers
  • A digital footprint is all of the information on-line about a person posted by that person or others, ____________. intentionall
    14·1 answer
  • I wonder how world is created
    12·2 answers
  • Hey I don’t have a question I’m just testing something on this app
    6·2 answers
  • Which career involves analyzing various factors that influence the customer decision-making process?
    13·1 answer
  • Calvin needs to design a simple yet professional interface for his users. Which option should he implement?
    9·2 answers
  • I need le help, darn ijourneys
    10·2 answers
  • Aubrey uses the following formula to calculate a required value. Which elements of the formula use mixed cell referencing?
    13·2 answers
  • A. Mohit has bought a new laptop. The laptop is not working as no software is installed in
    15·1 answer
  • Which website offers guidance on putting together a checklist to provide guidance on configuring and hardening operating systems
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!