Q1.Write suitable if statements for the following conditions: a) If the number is positive, add the number to the variable positivesum; else, add the number to the variable negativesum. b) If the slope is less than 0.5, set the variable flag to 0; else, set flag to 1.
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
![65
O Homework4.pdf >
Lecturer Ibtisam Alsari
Computer Programming1: Homework 4
Q1.Write suitable if statements for the following conditions:
a) If the number is positive, add the number to the variable positivesum;
else, add the number to the variable negativesum.
b) If the slope is less than 0.5, set the variable flag to 0; else, set flag to
1.
Q2.A senior salesperson is paid $800 a week, and a junior salesperson, $500
a week. Write a C++ program that accepts as input a salesperson's status in
the character variable status. If status cquals s, the senior salesperson's
salary should be displayed; otherwise, the junior salesperson's salary should
be displayed.
Q3.Write a program that input the month and the day. If the month entered
isn't between 1 and 12, display a message informing the user that an invalid
month has been entered. If the day entered isn't between I and 31, display
a message informing the user that an invalid day has been entered.
Q4.Write a C++ program that accepts a character as input data and
determines whether the character is a lowercase letter. A lowercase letter is
any character that's greater than or equal to "a" and less than or equal to "z"
If the entered character is a lowercase letter, display the message "The
character just entered is a lowercase letter." If the entered letter isn't
lowercase, display the message "The character just entered is not a
lowercase letter."
Q5.Write C++ program to compute and display a person's weekly salary
as determined by the following conditions: If the hours worked are less than
or equal to 40, the person receives $12.00 per hour; otherwise, the person
receives $480.00 plus $18.00 for each hour worked over 40 hours. The
Lecturer Ibtisam Alsari
program should request the hours worked as input and display the salary as
output.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0afb9de8-6aba-40ff-be49-ed00d43e2eed%2Fb1c78202-37f5-4b42-b943-7079efc06f63%2Fi0ljrb_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)