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

Which equation does the graph below represent? y = -1/3 x y = −3x y = 3x y = 1/3x
The triangle shon below has an area of the 75 units^2
water is a compound . explain​
Nueva York dista de Los Angeles aproximadamente 3000 mi; la diferencia de tiempo entre estas dos ciudades es de 3 h. Calcule la circunferencia de la Tierra.
Besides a means of gathering knowledge, how can the scientific method be useful when it is applied?
Briefly explain ONE historical event or development in the 1840s that contributed to causing the Mexican War
I have a chemistry question so do your thing for many points
this is my mom channel please subscribe​
How many oxygen atoms are contained in 112.2 g of iron sulfate FeSO,7H,0?
Which trinomial is a perfect square trinomial? (A) y2+6y+36 (B) y2+25y+200 (C) y2+18y+81 (D) y2+36y+60