In C++ write an application which takes positive or negative integers and returns the sum of each place in the number, such that 246 results in 12 and -88 results in -16. The program is called and runs with no prompt for input. The program reads exactly one signed integer from standard input. The program displays the sum of each digit of the number as a signed integer. This should be done in two files called main.cc and makefile.The result of calling the make application should be an executable named 01hw .
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ofstream file;
file.open ("01hw.txt");
int value,sum=0,rem;
cout<<"Enter any value : "<<endl;
cin>>value;
while(value)
{
rem=value%10;
value=value/10;
sum=sum+rem;
}
cout<<"Sum of Digits is "<<sum<<endl;
file << "Sum of Digits is "<<sum;
file.close();
return 0;
}
In C++ write an application which takes positive or negative integers and returns the sum of...
Write a C program that reads a list of positive integers from a file named "input.txt." and count number of odd integers and even integers and prints the results to another file called "results.txt". Please submit both the input and results files along with the c program.
I need to write a C++ program that reads two integers from a data filed called "integers.dat" The first integer should be low and the other one high. The program should loop through all integers between the low and high values and include the low and high integers and then display Display the integers in the file Displays the number of integers divisible by 5 OR 6, but not both. Displays the sum of the integers from condition 2 as...
in java 3) Sum. Write a program that prompts the user to read two integers and displays their sum. Your program should prompt the user to read the number again if the input is incorrect.
Problem 1: Write a program that reads a positive float number and displays the previous and next integers. Sample Run: Enter a float: 3.5 The previous and next integers are 3 and 4. Problem 2: Write a program that reads two integers and displays their sum, difference, product, and the result of their division. Sample Run: Enter two integers: 8 5 Sum: 8, Difference: 3, Product: 40, Division: 1.6 Problem 3: Write a program that reads a three-digit integer from...
C++ 3. Write a program that reads integers from a file, sums the values and calculates the average. a. Write a value-returning function that opens an input file named in File txt. You may "hard-code" the file name, i.e., you do not need to ask the user for the file name. The function should check the file state of the input file and return a value indicating success or failure. Main should check the returned value and if the file...
This is in Java. Write the application, TheSentinel to read a set of integers. Stop reading input when a non-integer is read. Use this exact prompt: System.out.print("Enter an integer or Q to quit: "); Note: you will actually quit on any non-integer. Do the following things: Find and print the sum of all the even numbers Find and print the smallest of the inputs Determine if the number 7 is in the input. If 7 is in the inputs, print "7...
Write a C program which reads sets of two integers and displays them and their sum. Continue readings sets of integers until their sum is zero, at which point terminate the program.
C++ write a function named subtract that takes two integers as parameters and returns the result of subtracting the second number from the first. i.e. int1 - int2 Change subtract to have default arguments for its two parameters. Pick whatever non-zero numbers you would like. Write a prototype for subtract before main so the program runs without error. I cant figure out the part where you pass no parameters, I've tried to set defailt values for the parameters but it...
Please Use C++ for coding . . Note: The order that these functions are listed, do not reflect the order that they should be called. Your program must be fully functional. Submit all.cpp, input and output files for grading. Write a complete program that uses the functions listed below. Except for the printodd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention...
(C++) Write a function, remove, that takes three parameters: an array of integers, the number of elements in the array, and an integer (say, removeItem). The function should find and delete the first occurrence of removeItem in the array. (Note that after deleting the element, the number of elements in the array is reduced by 1.) Assume that the array is unsorted. Also, write a program to test the function. Your program should prompt the user to enter 10 digits...