“sommet de gamme” Réponses codées

plage de somme

>>> sum(range(4))  # 0 + 1 + 2 + 3
6
Gendzi

sommet de gamme

// get sum from x to y
// initialization of variables
int x = 1, y = 100, sum = 0;
// loop from x to y and add up the current index i
for(int i = x; i = y; i++) sum += i;
std::cout << sum;
Minion OuO

SUMPRIMATION

//Java program to print the sum of numbers in a given rangeimport java.util.Scanner;public class sum_of_numbers_in_range{		public static void main(String[] args)	{		//scanner class declaration		Scanner sc = new Scanner(System.in);		//input from user		System.out.print("Enter starting number : ");						int start = sc.nextInt();		System.out.print("Enter ending number : ");						int end = sc.nextInt();		//declare a variable to store sum		int sum = 0;		//loop to add n natural numbers		for(int i = start ; i <= end ; i++)		sum=sum+i;		//display the sum		System.out.print("Sum of numbers in the range from "+start+" to "+end+" is "+sum);		//closing scanner class(not compulsory, but good practice)		sc.close();														}}
sree_007

Réponses similaires à “sommet de gamme”

Questions similaires à “sommet de gamme”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code