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
Pepsi [2]
4 years ago
15

Write a Visual Logic program that prompts the user for a whole number, N, that is less than or equal 50

Computers and Technology
1 answer:
Bezzdna [24]4 years ago
8 0

Answer:

//program in C++(Visual studio).

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variable

int num;

cout<<"Enter a number greater than 1 and less than 51:";

// read input number

cin>>num;

// check input is in between 1-50

if(num<=1||num>50)

{

    cout<<"Invalid input!!"<<endl;

    // exit the program

    exit;

}

else

{

// sum variable

    int sum=0;

    // find sum of all odd numbers

    for(int a=1;a<=num;a++)

    {

        if(a%2!=0)

        sum+=a;

    }

    // print sum

    cout<<"Sum of odd numbers from 1 to "<<num<<" is:"<<sum<<endl;

}

return 0;

}

Explanation:

Read a number from user and assign it to variable "num".If input number

is less than 1 or greater than 50 exit the program.otherwise find the sum

of all odd numbers from 1 to "num".Print the sum of odd numbers.

Output:

Enter a number greater than 1 and less than 51:-5                                                                          

Invalid input!!

Enter a number greater than 1 and less than 51:55                                                                          

Invalid input!!

Enter a number greater than 1 and less than 51:15                                                                          

Sum of odd numbers from 1 to 15 is:64

You might be interested in
Write a program that inputs a line of text and uses a stack object to print the line reversed.
Lina20 [59]

Answer:

#include <bits/stdc++.h>

using namespace std;

int main() {

   string ms;

   getline(cin,ms);

   stack<char>st;

   for(int i=0;i<ms.length();i++)//Inserting every element in the stack..

   {

       st.push(ms[i]);

   }

   while(!st.empty()) //doing operation until the stack is not empty..

   {

       char a=st.top();//accessing the top element of the stack...

       st.pop();//removing the head.

       cout<<a;//printing the character..

   }

return 0;

}

Input:-

murder

Ouput:-

redrum

Explanation:

An  easy way to reverse anything is to use stack.Since stack is LIFO type data structure so the last item in will be the first one to get out hence it reverses the elements.So inserting every element of the string into the stack of characters and then printing the every element of the stack from top to bottom.

8 0
3 years ago
A source is:
Anestetic [448]

Answer:

A. a primary work from which information is taken.

Explanation:

4 0
3 years ago
Read 2 more answers
________ is the actual speed of data transfer that is achieved between two nodes on a network and is always less than or equal t
Cerrena [4.2K]

<u>Throughput </u> is the actual speed of data transfer that is achieved between two nodes on a network and is always less than or equal to the data transfer rate.

<h3>What is used to transfer data packets between two or more networks?</h3>

A router is a networking device that forwards data packets between computer networks. Routers perform the traffic directing functions on the Internet.

<h3>What is throughput in data transfer?</h3>

In data transmission, network throughput is the amount of data moved successfully from one place to another in a given time period, and typically measured in bits per second (bps), as in megabits per second (Mbps) or gigabits per second (Gbps).

To learn more about Throughput , refer

brainly.com/question/25302150

#SPJ4

7 0
2 years ago
"the master boot record (mbr) method of partitioning hard drives is limited to what maximum size of drives
Vaselesa [24]
The answer is <span>2TB.  T</span>he master boot record (mbr) method of partitioning hard drives is limited to  2TB.  <span>The </span>Master Boot Record<span> (</span>MBR<span>) is the information in the first </span>sector<span> of any hard disk that identifies how and where an OS is located, so that it can be </span>boot<span> (loaded) into the computer's main storage or RAM.</span>
6 0
4 years ago
You have this code in your program.
earnstyle [38]

The line code will create array is G = array('f',[2.5, 3, 7.4])

<h3>What is meant by array ?</h3>

As opposed to defining distinct variables for each value, arrays are used to hold numerous values in a single variable. Set the data type (such as int) and the array name, followed by square brackets [, to construct an array.

An array is a collection of elements with the same type that are kept in nearby memory  locations and may each be separately referred to using an index to a special identifier. There is no need to declare five distinct variables when declaring an array of five int values (each with its own identifier).

In the C programming language, arrays are a derived data type that may contain primitive data types like int, char, double, float, etc.

To learn more about array refer to :

brainly.com/question/28061186

#SPJ1

6 0
1 year ago
Other questions:
  • Which audio editing effect uses the option ""Get Profile"" to execute its function?
    6·1 answer
  • What is the difference between a key escrow and a recovery agent? (Choose all that apply.)
    12·1 answer
  • Tom's Art Supplies used to sell art supplies through mail order catalogs, but the company's order takers often had difficulty de
    9·1 answer
  • Google Glass uses a projector that bounces a beam of light off a prism and projects the image directly on your ________. field o
    14·1 answer
  • What is a command-line program?
    8·2 answers
  • Multiple Choice
    8·1 answer
  • Please Help, Thank you!
    5·1 answer
  • Even though jdoe and jrock have the same password (i.e., hacker), their password hashes in the /etc/shadow file are different. W
    15·1 answer
  • Cybersquatters:_________.
    5·1 answer
  • a web server will utilize a directory protocol to enable users to authenticate with domain credentials. a certificate will be is
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!