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

100 POINTSwhat is efforescence? name the compound which show efflorescence.Support your answer .​
If a negatively charged object is brought near a neutrally charged sphere, what will happen? The electrons will move toward the charged object. The protons w
•••Help Fast!!!!!••• I met a traveller from an antique land who said too fast and trunkless legs of stone sand in the desert near them on the sand half su
The ratio of boys to girls is 2:3.How many girls are there if there is 80 students
please answer this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Failure to offer woman a seat on a crowded bus is usually considered a violation is
what are the 2 major groups of cells
In Korea, the Three Kingdoms were at peace and worked well with one another. True or False
How rolling friction is less than sliding friction?
choose the correct tanslation of following time 9:50 in spanish (plz help me