CODE:
#include <stdio.h>
int main()
{
int num,r,x=2,y=4,z=6;
scanf("%d", &num);
switch(num)
{
case 23: r=(x*y*z)/(x+y+z);
break;
case 75: r=((x*y)+(y*z))/(x*y*z);
break;
case 15: r=(x+y+z)+((x*z)+(z*y));
break;
default: r=num;
}
printf("The value of r is: %d", r);
return 0;
}
SCREENSHOT AND EXPLANATION WITH OUTPUT:
Read an integer from user and Write C- program to implement process based on value of...
Write a program which asks the user to enter an integer. Use switch statement to write out the numeric word (such as ONE) if the user's input is 1; (see the sample run output for the usr input 2 or 3); otherwise, write OUT OF RANGE. Below are few sample runs: If the user enters a 1, the program will print: ONE TWO THREE Or, if the user enters a 2, the program will print: TWO THREE Or, if the...
The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...
Write a Python program to prompt the user for an integer number. Assign this integer to a variable X. Then assign a variable Y to the X**3 (X to the power 3). Finally, assign the variable Z to the square root of Y and print the values of X, Y, and Z as shown in the example below. Use main() function to define and call the program. Example: Enter an integer number: 3 X = 3 if Y=X**3 then Y...
Write a C++ program that asks the user to input a decimal integer (i) and an integer radix from 2 to 16 (r) and outputs the value of iin radix r(base r). (HINT: use repeated division by base r) NOTE: show output screenshot
Program : Write a complete C++ program that Input: Read a positive integer from the keyboard (user) with proper prompt text and save it to a variable. The integer have up to five digits. Processing: From the right most digit, extract every digit from the input integer using modular operator %then save the digit to a separate variable. Remove the right most digit from the integer using integer division operator /. Repeat above two steps till all digits have been...
Summary: Write a C program that prompts the user to enter 2 positive integer numbers, display the numbers in 3 formats. Then check, whether the larger of the 2 is evenly divisible by the smaller. Detail: Write a complete C program, more complex than the typical "hello world" program. Prompt the user to enter 2 integer numbers that are not negative. After either entry, display that number again. Print the smaller in hexadecimal, in decimal, and in octal format. Include...
Activity 16-02 With proper indentation and comments, With proper interface/menu on the monitor Write C program of the following problem. This question involve repetition: while, and for statements This question involve selection: Don't use switch, use IF Marks is based on comments, indentation and interface/menu. You must try Choose any one value of j to print screen the following i Three input: num less than j, 21 and any valid number three input: A, B and X. Question: 1.0 From...
Lab-3B Two-Way Branch Write a MIPS program to read a positive integer and to determine and display whether it is an even number or odd. A positive integer X is odd if its last digit is 1. Otherwise X is odd if X AND 1 is 1, or in other words X is even if X AND 1 is 0. Example Input/Output Give a positive number X= 41 X is an odd number Give a positive number X= 40 X...
c++ please (1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...
In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read. Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. version1: use a while loop. version2: use a do-while loop. version 3: use a for loop. For each version, use a loop to input 10 int numbers from the user...