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
Troyanec [42]
3 years ago
15

Write a loop that asks the user to enter a number. the loop should iterate 10 times and keep a running total of the numbers ente

red.
Computers and Technology
1 answer:
Blababa [14]3 years ago
6 0
int sum = 0;
int number;
for (int i=0; i<10; i++) { 
   printf("Enter an integer number: ");
   scanf_s("%d", &number);
   sum += number;
}

printf("The sum is %d", sum);

You might be interested in
Write a complete program to do the following: The main program calls a method to read in (from an input file) a set of people's
zmey [24]

Answer:

See explaination

Explanation:

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class Donor {

public static void main(String[] args){

int idNumbers[] = new int[50]; //created two array each of 50 size

int donations[] = new int[50];

int donorCount=readFile(idNumbers, donations); //calling readfile function

System.out.println("--------------------Original record--------------------");

printDetails(idNumbers,donations,donorCount); //printing details

sortByDonorId(idNumbers,donations,donorCount);

System.out.println("--------------------Sort by donor id--------------------");

printDetails(idNumbers,donations,donorCount);

sortByDonation(idNumbers,donations,donorCount);

System.out.println("--------------------Sort by donation amount--------------------");

printDetails(idNumbers,donations,donorCount);

}

private static void sortByDonation(int[] idNumbers, int[] donations, int donorCount) {

for(int i=0;i<=donorCount;i++){

for(int j=i+1;j<=donorCount;j++){

if(donations[i]>donations[j]){ //comparison based on donations

int temp = idNumbers[i];

idNumbers[i] = idNumbers[j];

idNumbers[j] = temp;

temp = donations[i];

donations[i] = donations[j];

donations[j] = temp;

}

}

}

}

private static void sortByDonorId(int[] idNumbers, int[] donations, int donorCount) {

for(int i=0;i<=donorCount;i++){

for(int j=i+1;j<=donorCount;j++){

if(idNumbers[i]>idNumbers[j]){ //comparison based on donor number

int temp = idNumbers[i];

idNumbers[i] = idNumbers[j];

idNumbers[j] = temp;

temp = donations[i];

donations[i] = donations[j];

donations[j] = temp;

}

}

}

}

public static void printDetails(int[] idNumbers, int[] donations, int donorCount){

System.out.printf("%-5s%s"," ","Donor information"); //using printf for format output

System.out.printf("\n%-20s%-20s","ID number","donations");

for(int i=0;i<=donorCount;i++){

System.out.printf("\n%-20s%-20s",idNumbers[i],donations[i]);

}

System.out.println();

}

public static int readFile(int idNumbers[],int donations[]){

File file = new File("input.txt"); //reading data from this file

Scanner reader;

int donorIndex=-1; //keep track of number of records

try {

reader = new Scanner(file);

while(reader.hasNext()){

donorIndex++;

String line = reader.nextLine();

idNumbers[donorIndex] = Integer.parseInt(line.split(" ")[0]); //spliting line by space,0 is idnumber

donations[donorIndex] = Integer.parseInt(line.split(" ")[1]); //spliting line by space,1 is donations

}

reader.close();

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return donorIndex;

}

}

3 0
3 years ago
How many apostrophes or quotation marks in a row should you use to begin and end a multi-line string?
const2013 [10]
Answer is 4 (One)
There should be so many apostrophes or quotation marks in a row .
6 0
3 years ago
Read 2 more answers
2.13 LAB: Branches: Leap Year
Neporo4naja [7]

Answer:

The program in Python is as follows:

year = int(input("Enter a year: "))

print(year,end=" ")

if year % 4 == 0:

  if year % 100 == 0:

      if year % 400 == 0:           print("is a leap year")

      else:           print("is not a leap year")

  else:       print("is a leap year")

else:   print("is not a leap year")

Explanation:

This gets input for year

year = int(input("Enter a year: "))

This prints year, followed by a blank

print(year,end=" ")

If year is divisible by 4

if year % 4 == 0:

If yes, check if year is divisible by 100

  if year % 100 == 0:

If yes, check if year is divisible by 400; print leap year if true

      if year % 400 == 0:           print("is a leap year")

print not leap year if year is not divisible by 400

      else:           print("is not a leap year")

print leap year if year is not divisible by 100

  else:       print("is a leap year")

print leap year if year is not divisible by 4

else:   print("is not a leap year")

5 0
3 years ago
All dogs = 199999990158161231
devlian [24]

Answer:

C=D cause d spells dogs jk I really dont know

3 0
3 years ago
Read 2 more answers
Explain two ways by which the calendar meets or fails to meet the criteria of showing the correct data
gtnhenbr [62]

Answer:

The two ways the calendar meets the criteria of showing the correct date are;

1) The calendar can give dates in the 12 months in a year

2) The calendar can show up to the 31 different days in a month

Explanation:

The two ways in which the calendar meets the criteria of showing the correct date are;

1) The number number of long blocks with 4 different months each = Three

Therefore, the total number of months the blocks can hold = 3 × 4 months = 12 months = The number of months in a year

2) The number of faces on each dice = 6 faces

The number of dice = 2 dice

The total number of faces = 12

The number of identical faces = 2 (11th and 22nd of the month)

The number of unique faces = 10

The number of combinations of the dices = ₁₀C₂ = 45

The number of combination of faces required to show = 1 to 31 = 31 combination

Therefore, there are adequate combinations on the dice to show all the dates of month

7 0
3 years ago
Other questions:
  • Driving while wearing headphones or earphones
    12·2 answers
  • 7.12 LAB: Contains the character
    12·2 answers
  • What are personal skills? A manner of individual style How a person manages and expresses oneself One's ability to excel at spor
    13·2 answers
  • Which of the following is true? A)Checks and Debit Cards both withdraw money directly from a bank account. B)Checks are the most
    13·2 answers
  • A tablet computer transmits a file over a wi-fi link to an access point.
    13·1 answer
  • Which small-group format would be most appropriate for the following situation? A large sporting event is coming to town. Key me
    14·2 answers
  • Is badlion safe and how ?
    14·1 answer
  • 17. When an industrial electrical circuit requires a 220 VAC single phase power supply, the electric power supply circuit is nor
    7·1 answer
  • Does anyone know what to do when brainly won't let you answer questions? I click on answer question and then it just sits there
    15·2 answers
  • Here’s my last question
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!