In this programming assignment, you will write a simple program in C that outputs one string. This assignment is mainly to help you get accustomed to submitting your programming assignments here in zyBooks. Write a C program using vim that does the following. Ask for an integer input from the user. Do not print any prompt for input. If the number is divisible by 3, print the message CS If the number is divisible by 5, print the message 1714 If the number is divisible by both 3

Answers

Answer 1

Answer:

In C:

#include <stdio.h>

int main() {

   int mynum;

   scanf("%d", &mynum);

   if(mynum%3 == 0 && mynum%5 != 0){

       printf("CS");    }

   else if(mynum%5 == 0 && mynum%3 != 0){

       printf("1714");    }

   else if(mynum%3 == 0 && mynum%5 == 0){

       printf("CS1714");    }

   else    {

       printf("ERROR");   }

   return 0;

}

Explanation:

This declares mynum as integer

   int mynum;

This gets user input

   scanf("%d", &mynum);

This condition checks if mynum is divided by 3. It prints CS, if true

   if(mynum%3 == 0 && mynum%5 != 0){

       printf("CS");    }

This condition checks if mynum is divided by 5. It prints 1714, if true

   else if(mynum%5 == 0 && mynum%3 != 0){

       printf("1714");    }

This condition checks if mynum is divided by 3 and 5. It prints CS1714, if true

   else if(mynum%3 == 0 && mynum%5 == 0){

       printf("CS1714");    }

This condition checks if num cannot be divided by 3 and 5. It prints ERROR, if true

   else    {

       printf("ERROR");    }


Related Questions

What is media framing?

Answers

Answer:

media frame all news items by specific values, facts, and other considerations, and endowing them with greater apparent for making related judgments

Explanation:

Consider the following method.


public int locate(String str, String oneLetter)

{
int j = 0;
while(j < str.length() && str.substring(j, j+1).compareTo*oneLetter < 0)
{
j++;
}
return j;
}

Which of the following must be true when the while loop terminates?

a. j == str.length()
b. str.substring(j, j+1) >= 0
c. j <= str.length() || str.substring(j, j+1).compareTo(oneLetter) > 0
d. j == str.length() || str.substring(j, j+1).compareTo(oneLetter) >= 0
e. j == str.length() && str.substring(j, j+1).compareTo(oneLetter) >= 0

Answers

Answer:

All

Explanation:

From the available options given in the question, once the while loop terminates any of the provided answers could be correct. This is because the arguments passed to the while loop indicate two different argument which both have to be true in order for the loop to continue. All of the provided options have either one or both of the arguments as false which would break the while loop. Even options a. and b. are included because both would indicate a false statement.

The Fast as Light Shipping company charges the following rates. Weight of the item being sent Rate per 100 Miles shipped 2kg or less. $0.25 Over than 2 kg but not more than 10 kg $0.30 Over 10 kg but not more than 20 kg. $0.45 Over 20 kg, but less than 50kg. $1.75 Write a program that asks for the weight of the package, and the distance to be sent. And then displays the charge.

Answers

Answer:

weight = float(input("Enter the weight of the package: "))

distance = float(input("Enter the distance to be sent: "))

weight_charge = 0

if weight <= 2:

   weight_charge = 0.25

elif 2 < weight <= 10:

   weight_charge = 0.3

elif 10 < weight <= 20:

   weight_charge = 0.45

elif 20 < weight <= 50:

   weight_charge = 1.75

if int(distance / 100) == distance / 100:

  d = int(distance / 100)

else:

   d = int(distance / 100) + 1

   

total_charge = d * weight_charge

print("The charge is $", total_charge)

Explanation:

*The code is in Python.

Ask the user to enter the weight and distance

Check the weight to calculate the weight_cost for 100 miles. If it is smaller than or equal to 2, set the weight_charge as 0.25. If it is greater than 2 and smaller than or equal to 10, set the weight_charge as 0.3. If it is greater than 10 and smaller than or equal to 20, set the weight_charge as 0.45. If it is greater than 20 and smaller than or equal to 50, set the weight_charge as 1.75

Since those charges are per 100 miles, you need to consider the distance to find the total_charge. If the int(distance / 100) is equal to (distance / 100), you set the d as int(distance / 100). Otherwise, you set the d as int(distance / 100) + 1. For example, if the distance is 400 miles, you need to multiply the weight_charge by 4, int(400/100) = 4. However, if the distance is 410, you get the int(400/100) = 4, and then add 1 to the d for the extra 10 miles.

Calculate the total_charge, multiply d by weight_charge

Print the total_charge

During TCP/IP communications between two network hosts, information is encapsulated on the sending host and decapsulated on the receiving host using the OSI model. Match the information format with the appropriate layer of the OSI model.

a. Packets
b. Segments
c. Bits
d. Frames

1. Session Layer
2. Transport Layer
3. Network Layer
4. Data Link Layer
5. Physical Layer

Answers

Answer:

a. Packets - Network layer

b. Segments - Transport layer

c. Bits - Physical layer

d. Frames - Data link layer

Explanation:

When TCP/IP protocols are used for communication between two network hosts, there is a process of coding and decoding also called encapsulation and decapsulation.

This ensures the information is not accessible by other parties except the two hosts involved.

Operating Systems Interconnected model (OSI) is used to standardise communication in a computing system.

There are 7 layers used in the OSI model:

1. Session Layer

2. Transport Layer

3. Network Layer

4. Data Link Layer

5. Physical Layer

6. Presentation layer

7. Application layer

The information formats given are matched as

a. Packets - Network layer

b. Segments - Transport layer

c. Bits - Physical layer

d. Frames - Data link layer

Consider an entity set Person, with attributes social security number (ssn), name, nickname, address, and date of birth(dob). Assume that the following business rules hold: (1) no two persons have the same ssn; (2) no two persons have he same combination of name, address and dob. Further, assume that all persons have an ssn, a name and a dob, but that some persons might not have a nickname nor an address.
A) List all candidate keys and all their corresponding superkeys for this relation.
B) Write an appropriate create table statement that defines this entity set.

Answers

Answer:

[tex]\pi[/tex]

Explanation:

when you look directly at a camera lens, it may seen like there is only one lens, but entering light actually passes through a series of lenses, or_____, that bend the light and send it on its way to be focused on the film or digital. chip

Frame
Optics
Flash
SD cARD

Answers

Answer:

The answer should be optics...

Explanation:

If aa person is known to have look at a camera lens straight and light passes via a number of lenses, or Optics.

What is Optics?

This is known to be an aspect  of physics that looks at the attributes and properties of light, such as its relationship with matter, etc.

Therefore,  If a person is known to have look at a camera lens straight and light passes via a number of lenses, or Optics.

Learn more about Optics from

https://brainly.com/question/18300677

#SPJ9

Other Questions
plzzzzzzzzzzzzzzz help liters = 5,000 milliliters The cell theory is a scientific explanation about the characteristics of cells in living things discovery of cells occurred in the 1600s which piece of equipment my students in science class used to investigate the cell theory All I need is the congruency statement and postulate ( SSS,HL,SAS,AAS,ASA,Not crungruent) Which group of Tenneseans lost their right to vote as a result of the constitution change? HELP PLEASE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Which of the following is NOT a basic element of communication?A. SenderB. MessageC. Thought processD. Receiver i need help is it yes or no I need help plss dont lieplss and thank you Natalie bought a 3 - pack of erasers for $1.47. How much did each eraser cost? (01.05 MC)Which of the following best describes the location of the first river valley civilizations? Civilizations developed in locations ideal for trade with natural defenses to prevent attack. Civilizations developed in remote areas so that they did not have to spend tax money on defense walls. Civilizations developed in areas well suited for agriculture but relied on trade for everything else. Civilizations developed in areas ideal for trade but low in natural resources and defenses. The line of best fit for a scatterplot is shown what is the equation of this line of best fit in slope intercept form?(pic provided)1. y=-6x+3/42.y=6x+3/43. y=-3/4x+64. y=3/4x+6 I am doing a power point about elbert r. robinson so can you explain about elbert r robinson? , please What lines are perpendicular to 3x+6y=5 spanish midterm help How was early Earth's atmosphere different from today's atmosphere? 2(5x-9) = 11x-3 find m the stigma is the structure which receive the pollen grains stimulates the pollen grain to germinate and reach the ovary Pls place the words in the right place I'll give brainless and the points! You've created a new programming language, and now you've decided to add hashmap support to it. Actually you are quite disappointed that in common programming languages it's impossible to add a number to all hashmap keys, or all its values. So you've decided to take matters into your own hands and implement your own hashmap in your new language that has the following operations:insert x y - insert an object with key x and value y.get x - return the value of an object with key x.addToKey x - add x to all keys in map.addToValue y - add y to all values in map.To test out your new hashmap, you have a list of queries in the form of two arrays: queryTypes contains the names of the methods to be called (eg: insert, get, etc), and queries contains the arguments for those methods (the x and y values).Your task is to implement this hashmap, apply the given queries, and to find the sum of all the results for get operations.ExampleFor queryType = ["insert", "insert", "addToValue", "addToKey", "get"] and query = [[1, 2], [2, 3], [2], [1], [3]], the output should be hashMap(queryType, query) = 5.The hashmap looks like this after each query:1 query: {1: 2}2 query: {1: 2, 2: 3}3 query: {1: 4, 2: 5}4 query: {2: 4, 3: 5}5 query: answer is 5The result of the last get query for 3 is 5 in the resulting hashmap.For queryType = ["insert", "addToValue", "get", "insert", "addToKey", "addToValue", "get"] and query = [[1, 2], [2], [1], [2, 3], [1], [-1], [3]], the output should be hashMap(queryType, query) = 6.The hashmap looks like this after each query:1 query: {1: 2}2 query: {1: 4}3 query: answer is 44 query: {1: 4, 2: 3}5 query: {2: 4, 3: 3}6 query: {2: 3, 3: 2}7 query: answer is 2The sum of the results for all the get queries is equal to 4 + 2 = 6.Input/Output[execution time limit] 4 seconds (py3)[input] array.string queryTypeArray of query types. It is guaranteed that each queryType[i] is either "addToKey", "addToValue", "get", or "insert".Guaranteed constraints:1 queryType.length 105.[input] array.array.integer queryArray of queries, where each query is represented either by two numbers for insert query or by one number for other queries. It is guaranteed that during all queries all keys and values are in the range [-109, 109].Guaranteed constraints:query.length = queryType.length,1 query[i].length 2.[output] integer64The sum of the results for all get queries.[Python3] Syntax Tips# Prints help message to the console# Returns a stringdef helloWorld(name):print("This prints to the console when you Run Tests")return "Hello, " + name