kofitakyi549
kofitakyi549 kofitakyi549
  • 20-02-2021
  • Computers and Technology
contestada

write an algorithm and draw a flowchart to calculate the sum of of the first 10 natural numbers starting from 1​

Respuesta :

AlyssaSilverStone
AlyssaSilverStone AlyssaSilverStone
  • 20-02-2021

Answer:

#include <stdio.h>

void main()

{

int j, sum = 0;

printf("The first 10 natural number is :\n");

for (j = 1; j <= 10; j++)

{

sum = sum + j;

printf("%d ",j);

}

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

}

Within a loop

Step 1: Initialize a variable to 1 (say x=1)

Step 2: Specifiy the condition

In this case x<=10

Step 3: Increment the variable by 1

using increment operator x++

OR

simply x+=1(x=x+1)

Step 4: Print the value of variable

Terminate the loop

Explanation:

Answer Link

Otras preguntas

Solve the simultaneous equations C^2+d^2=5 and 3c+4d=2
Need help does anyone know
What is 6/5 as a fraction
how do you think establishing a written form of music and music technology, affected music as well as culture? Do you think it helped or hindered them? Explain
Elizabeth is baking oatmeal cookies . A single batch used 3/4 teaspoons of vanilla. If Elizabeth is mixing the ingredients for six batches at the same time , ho
How to mentally subtract smaller numbers from bigger numbers?
mapiya writes a series of novels. she earned $75000 for the first book, and her cumulative earnings double with each sequel that she writes.write a function tha
What type(s) of bond(s) does carbon have a tendency to form?
please help! I need help with these three problems. thank you!
John's age is 9 more than three times Rick's age. Which expression represents this?