Question

Assume that an integer value is already stored in x. Write a conditional statement that will...

Assume that an integer value is already stored in x.

Write a conditional statement that will print "Yes" if x is not an exact multiple of 3 and "No" otherwise.

Proper indentation is required for full marks.

Homework Answers

Answer #1

The conditional operator or turnory operator ( ? : ) is used to represent conditional statement.

  • In C : Condition ? statement 1 : statement 2
  • In Python : "statement 1" if condition else "statement 2"

If the condition is true, it will executes first statement else executes second statement.

Here to check x is multiple of 3, condition is x % 3 == 0

So if it is true, it will print yes else it will print no.

So, conditional statement fro the same is

print("yes") if x % 3 == 0 else print("no")

You can write the same statement in C is as follows

x % 3 == 0 ? printf("yes") : printf("no")

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
With C language Write the rand statement needed to assign x to a random integer from...
With C language Write the rand statement needed to assign x to a random integer from 1200 to 1500.
Write spim program and execute it on mars. Your program reads two integer values x and...
Write spim program and execute it on mars. Your program reads two integer values x and y. Write a function called sum that gets x and y passed as parameters and return the sum of odd values between x and y inclusive. In addition write another function called even that gets x and y as parameters and returns the count of all even numbers between x and y inclusive. Also in main print the quotient and remainder of diving y...
2. Assume that n has been declared as an integer variable and received a positive value...
2. Assume that n has been declared as an integer variable and received a positive value which is unknown to us, you write statements to sum all values from 1 to n with a step size at 2 and print out the summation. For example, if n is 4, the summation is 4 because 1 + 3 equals 4; if n is 5 the summation is 9 because 1 + 3 + 5 equals 9.
Python: Write a program that prompts the user to enter a positive integer value, and compute...
Python: Write a program that prompts the user to enter a positive integer value, and compute the following sequence: • If the value is even, halve it. • If it's odd, multiply by 3 and add 1. • Repeat this process until the value is 1, printing out each value. • Then print out how many of these operations you performed. If the input value is less than 1, print a message containing the word Error and exit the program....
Q2- Write a function solution that, given an integer N, returns the maximum possible value obtained...
Q2- Write a function solution that, given an integer N, returns the maximum possible value obtained by inserting one '5' digit inside the decimal representation of integer N. Examples: 1. Given N = 268, the function should return 5268. 2. Given N = 670, the function should return 6750. 3. Given N = 0, the function should return 50. 4. Given N = −999, the function should return −5999. Assume that: N is an integer within the range [−8,000..8,000].
Function Example: Write a Python function that receives two integer arguments and writes out their sum...
Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables. def writer(n1, n2): sum = n1 + n2 product = n1*n2 print("For the numbers", n1, "and", n2) print("the sum is", sum) print("and the product is", product) ... 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both...
1. How many times the loop below will be executed? What is the value of variable...
1. How many times the loop below will be executed? What is the value of variable counter after the loop? counter = 1 while counter < 7: counter+=2 print(counter) 2. An integer is stored in a variable MyInt. Write the Python if statement to test if MyInt is even number or odd number, and print a message to show “It is even number.” or “It is an odd number”. 3. Complete the python below that asks user to enter the...
1.Assume that x has a normal distribution with the specified mean and standard deviation. Find the...
1.Assume that x has a normal distribution with the specified mean and standard deviation. Find the indicated probability. (Round your answer to four decimal places.) μ = 108; σ = 15 P(x ≥ 90) = 2.Assume that x has a normal distribution with the specified mean and standard deviation. Find the indicated probability. (Round your answer to four decimal places.) μ = 103;σ = 10 P(x ≥ 120) = 3.During the Computer Daze special promotion, a customer purchasing a computer...
One way to represent a very large integer (one that won't fit into a variable of...
One way to represent a very large integer (one that won't fit into a variable of type short, int, or even long) is to use an array. The array is of type int, so each element in the array can hold an integer -- we will store just one digit of our number per array element. So if a user entered 2375, it might be stored as -------------------------- | 2 | 3 | 7 | 5 | ... | --------------------------...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you start doing anything… This project involves implementing a simple university personnel management program. The program contains two different kinds of objects: students and faculty. For each object, the program stores relevant information such as university ID, name, etc. Different information is stored depending on the type of the object. For example, a student has a GPA, while a faculty has a title and department...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT