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
sveticcg [70]
3 years ago
11

write a loop that reads positive integers from standard input and that terminates when it reads an integers that is not positive

. After the loop terminates , it prints out separate by a space on a single line
Computers and Technology
1 answer:
rjkz [21]3 years ago
7 0
I found this loop. But it ends like this: After the loop terminates, <span>it prints out the sum of all the even integers read. Declare any variables that are needed.</span>

<span>int sum=0;
int num=1;
while(num > 0){
cin >> num;
if ((num % 2)==0 & (num>0)){
sum+=num;
}
}
cout << sum;

I'm not familiar with coding but I think you can work on this loop and edit it according to your requirement.</span>
You might be interested in
Input 10 integers and display the following:
LekaFEV [45]

Answer:

// code in C++

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

   // variables

   int sum_even=0,sum_odd=0,eve_count=0,odd_count=0;

   int largest=INT_MIN;

   int smallest=INT_MAX;

   int n;

   cout<<"Enter 10 Integers:";

   // read 10 Integers

   for(int a=0;a<10;a++)

   {

       cin>>n;

       // find largest

       if(n>largest)

       largest=n;

       // find smallest

       if(n<smallest)

       smallest=n;

       // if input is even

       if(n%2==0)

       {  

           // sum of even

           sum_even+=n;

           // even count

           eve_count++;

       }

       else

       {

           // sum of odd    

          sum_odd+=n;

          // odd count

          odd_count++;

       }

   }

   

   // print sum of even

   cout<<"Sum of all even numbers is: "<<sum_even<<endl;

   // print sum of odd

   cout<<"Sum of all odd numbers is: "<<sum_odd<<endl;

   // print largest

   cout<<"largest Integer is: "<<largest<<endl;

   // print smallest

   cout<<"smallest Integer is: "<<smallest<<endl;

   // print even count

   cout<<"count of even number is: "<<eve_count<<endl;

   // print odd cout

   cout<<"count of odd number is: "<<odd_count<<endl;

return 0;

}

Explanation:

Read an integer from user.If the input is greater that largest then update the  largest.If the input is smaller than smallest then update the smallest.Then check  if input is even then add it to sum_even and increment the eve_count.If the input is odd then add it to sum_odd and increment the odd_count.Repeat this for 10 inputs. Then print sum of all even inputs, sum of all odd inputs, largest among all, smallest among all, count of even inputs and count of odd inputs.

Output:

Enter 10 Integers:1 3 4  2 10 11 12 44 5 20                                                                                

Sum of all even numbers is: 92                                                                                            

Sum of all odd numbers is: 20                                                                                              

largest Integer is: 44                                                                                                    

smallest Integer is: 1                                                                                                    

count of even number is: 6                                                                                                

count of odd number is: 4

3 0
4 years ago
Write a program that removes all spaces from the given input.
sasho [114]

Explanation:

#include<iostream>

#include<string.h>

using namespace std;

char *removestring(char str[80])

{

   int i,j,len;

   len = strlen(str);

   for( i = 0; i < len; i++)

   {

       if (str[i] == ' ')

       {

           for (j = i; j < len; j++)

               str[j] = str[j+1];

           len--;

       }

   }

   return str;

}

int main ()

{  

char  str[80];

   cout << "Enter a string : ";

   cin.getline(str, 80);

   strcpy(removestring(str), str);

   cout << "Resultant string : " << str;

   return 0;

}

In this program the input is obtained as an character array using getline(). Then it is passed to the user-defined function, then each character is analyzed and if space is found, then it is not copied.

C++ does not allow to return character array. So Character pointer is returned and the content is copied to the character array using "strcpy()". This is a built in function to copy pointer to array.

5 0
4 years ago
Is it possible to connect a piano using a micro usb instead of a midi cord?
ValentinkaMS [17]

Answer:

MIDI might be a better option.

Explanation:

USB is much faster, and just as reliable as a MIDI cable. An external disk drive with a USB connection transmits data thousands of times faster than a single MIDI instrument with no problems! If you want to use very long cables, for on-stage work for example, MIDI might be a better option.

8 0
3 years ago
Which form of investigation aims at checking whether or not a target system is subject to attack based on a database of tests, s
VikaD [51]

Answer:

<em>Empirical technical </em>research has a fundamental objective, which is to provide objective and independent information on the quality of the product to the interested party or stakeholder. It is one more activity in the quality control process.

Explanation:

Testing is basically a set of activities within software development. Depending on the type of tests, these activities may be implemented at any time during said development process. There are different software development models, as well as test models. Each one has a different level of involvement in development activities.

In a full penetration testing process, there are pre-instances to run this tool, but to take the first steps it is probably the best way to start. Nmap is a network scanning tool that allows you to identify what services are running on a remote device, as well as the identification of active computers, operating systems on the remote computer, existence of filters or firewalls, among others.

In simple words, when a server or device is going to be attacked, the attacker can carry out different attacks depending on the service: it is not the same to damage a web server, a database server or a perimeter router. Therefore, in any deployment, the first step will be to identify the services in the infrastructure, to decide how to proceed and, considering that in a penetration test the steps of an attacker are “imitated”, it will also be started in the same way.

5 0
4 years ago
What would be considered a benefit of using simulation in the modern industry field? Simulation increases labor and manufacturin
Sholpan [36]
Simulation predicts possible problems before they occur
5 0
2 years ago
Other questions:
  • Clifford created a table using OpenOffice Writer and entered some information into the table. Later, he needed to add more rows
    15·2 answers
  • Many programming languages require a ____ to create executable files.
    10·1 answer
  • What adds the element carbon to the environment
    10·2 answers
  • Administrators who are wary of using the same tools that attackers use should remember that a tool that can help close an open o
    6·1 answer
  • I need them on this question
    5·1 answer
  • How can you ensure that the website you are using is secured?
    8·1 answer
  • Focusing on a target market makes it harder to develop products and services that specific groups of customers want.
    10·1 answer
  • Using the arrow key you can adjust the position of a selection in increments of
    7·1 answer
  • Why does my wifi keep disconnecting and reconnecting?
    9·1 answer
  • What method does a gsm network use to separate data on a channel?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!