I will edit this if you edit your question..
Im confused. This is not a question..
Answer:
Following are the program in the Python Programming Language.
#declare variable and initialize to 0
sum = 0
#read the following file
file = open('numbers.txt', 'r')
#set the for loop
for n in file:
#convert the file string into the integer and perform sum.
sum += int(n)
Explanation:
<u>The following are the description of the program</u>.
- Firstly, declare variable 'sum' and initialize the integer type value i.e., 0.
- Set the variable 'file' that only read the following file text i.e., 'numbers.txt'.
- Set the for loop that read the content of the file and store in the variable 'n' one by one.
- Finally, er convert the following string in to the integer and perform the addition.
Answer:
Opcode = 3
Mode =2
RegisterRegister =7
AR = 20
Explanation:
a) Number of addressing modes = 4 = 22 , So it needs 2 bits for 4 values
Number of registers = 65 = 1000001 in binary , So it needs 7 bits
AR = 20
Bits left for opcode = 32 -(2+7+20) = 3
Answer:
The answer to this question can be given as
The potential problem with the loop is it's counts when the user enters -1 from the keyboard, so the count will too many.
Explanation:
In the program there some line is missing. So the right program of the question can be given as:
import java.util.*; //import package for take input from user.
public class Main //define main class.
{
public static void main(String[] args)//define main function
{
Scanner scan=new Scanner(System.in); //creating object.
//print values.
System.out.print("Enter integers. Enter -1 to exit.");
System.out.println(" Count of integers entered will be returned.");
int n=0,c=0; //declaring integer variable.
while (n != -1) //loop
{
n = scan.nextInt(); //take input by user and hold on variable n.
c++;
}
System.out.println(c); //print value.
}
}
output:
Enter integers. Enter -1 to exit. Count of integers entered will be returned.
-1
1