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
One disadvantage of online information sharing is that:
zubka84 [21]

Answer:

its b i just took the test

Explanation:

3 0
3 years ago
Read 2 more answers
Need help with this please
Rasek [7]

Answer:

4. let eggs = 5

let bread = 10

let soda = 6

5.

let total = eggs+bread+soda

4 0
3 years ago
What are the chances that we are living in a simulation? (Percentage)
harkovskaia [24]
Round about 95% Chance to living in a Simulation
5 0
3 years ago
Read 2 more answers
(50 points) {brainliest}
Elena-2011 [213]

C is the answer

bc i know it is

4 0
3 years ago
Read 2 more answers
Write a for loop that displays your name and student number 12 times.
d1i1m1o1n [39]

Answer:

// here is code in java.

import java.util.*;

// class definition

class Solution

{

// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // scanner object

       Scanner s=new Scanner(System.in);

        // variables

      String s_name;

      int s_num;

      System.out.print("Please enter the name:");

       // read the student name

      s_name=s.nextLine();

      System.out.print("Please enter the number:");

       // read the student number

      s_num=s.nextInt();

       // print name and number 12 times

      for(int i=0;i<12;i++)

      {

          System.out.println(s_name+"----"+s_num);

      }

   }catch(Exception ex){

       return;}

}

}

Explanation:

Create a scanner class object to read input from user.Read the student name and the number from user and assign them to variable "s_name" and "s_num".Print the student name and number 12 times with the help of for loop.

Output:

Please enter the name:Mary Kaur

Please enter the number:123456

Mary Kaur----123456

Mary Kaur----123456

Mary Kaur----123456

Mary Kaur----123456

Mary Kaur----123456

Mary Kaur----123456

Mary Kaur----123456

Mary Kaur----123456

Mary Kaur----123456

Mary Kaur----123456

Mary Kaur----123456

Mary Kaur----123456

5 0
4 years ago
Other questions:
  • Is a display, or monitor, considered a piece of computer hardware
    15·1 answer
  • A(n) _____ is essentially a flash-based replacement for an internal hard drive.
    13·1 answer
  • How do i divid 521 to the nearest tenth
    12·2 answers
  • If the ____________ is broken on a laptop, chances are other parts are also broken.
    12·1 answer
  • Which programming language is fortnite created in?
    11·2 answers
  • Talia was a scientist whose research compared the birth rates of young
    12·2 answers
  • Which guideline would not promote energy conservation?
    15·1 answer
  • Please help it’s timed
    11·1 answer
  • Define management styles
    14·2 answers
  • What tool allows you to search external competitive intelligence research?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!