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
snow_lady [41]
3 years ago
7

11.19 LAB: Max magnitude Write a function max_magnitude() with two integer input parameters that returns the largest magnitude v

alue. Use the function in a program that takes two integer inputs, and outputs the largest magnitude value. Ex: If the inputs are: 5 7 the function returns: 7 Ex: If the inputs are: -8 -2 the function returns: -8 Note: The function does not just return the largest value, which for -8 -2 would be -2. Though not necessary, you may use the built-in absolute value function to determine the max magnitude, but you must still output the input number (Ex: Output -8, not 8). Your program must define and call the following function: def max_magnitude(user_val1, user_val2)

Computers and Technology
1 answer:
AlekseyPX3 years ago
3 0

Answer:

# the user is prompt to enter first value

user_val1 = int(input("Enter first value: "))

# the user is prompt to enter second value

user_val2 = int(input("Enter second value: "))

# max_magnitude function is defined

# it takes two parameters

def max_magnitude(user_val1, user_val2):

# if statement to compare the values

# it compare the absolute value of each

if(abs(user_val2) > abs(user_val1)):

return user_val2

elif (abs(user_val1) > abs(user_val2)):

return user_val1

# max_magnitude is called with the

# inputted value as parameter

print(max_magnitude(user_val1, user_val2))

Explanation:

The code is written in Python and well commented. A sample image of program output is attached.

You might be interested in
Comment on the following 2 arrays. int *a1[8]; int *(a2[8]); a1 is pointer to an array; a2 is array of pointers a1 is pointer to
Hitman42 [59]

Answer:

The answer is "a1 and a2 is an array of pointers".

Explanation:

In this question, A collection of pointers refers to an array of elements where each pointer array element points to a data array element. In the above-given statement, the two-pointer type array "a1 and a2" is declared that holds the same size "8" elements in the array, and each element points towards the array's first element of the array, therefore, both a1 and a2 are pointer arrays.

5 0
3 years ago
Where is voice data stored in Android?
Dafna1 [17]
Inside its internal hard-drive and your google account!
8 0
2 years ago
1. Information integrity ensures that data can be modified only by appropriate mechanisms.
GrogVix [38]

Answer:

1. True

2. True

3. False

4. False

Explanation:

1. Information integrity is a term in computer business that describes the degree of accuracy, reliability and dependency of an information content, process and system.

The main purpose of Information integrity is to prevent or protect information from accidental or intentional but unauthorized changes.

Hence, it helps to ensure that data can be modified only by appropriate mechanism.

2. Pairing threats with vulnerabilities is a pair of risk analysis, that sets to determine the type of vulnerabilities a system or organization has, which can be paired with valid threats. Hence, the kind of risk involved in the vulnerability threats, can then be addressed.

3. Knowledge based identification (authentication) system which involves password or PIN are the most common form of authentication methods. Ranges from different devices such as phones and PC to platform such as website.

4. Biometric is a type of user authentication that relies on the measurement and calculation of the shape of the body, such as fingerprint, palm veins, face recognition, DNA, palm print, hand geometry, iris recognition, retina and odour/scent. It is often referred to as Physiological characteristics of Biometric system.

6 0
3 years ago
Read 2 more answers
Input and Output. Keep the program running in a Do-While Loop or While Loop. Conditional statements. User defined functions for
kolezko [41]

Answer:

See explaination

Explanation:

#include <stdio.h>

#define MAX_SIZE 50

#define password "mypassword"

void addProduct(struct product arr[], struct product p);

void deleteProduct(struct product arr[], char[] productId)

void editProduct(struct product arr[], int incrementKey, char[] productId) //incrementKey is the how much quanity user wants to add of the existing product

void display(struct product arr[]);

void saleProduct(struct product arr[], char[] productId, int soldItems);

void displayHighestSaleProduct(struct product arr[]);

void displayProductWithZeroQuantity(struct product arr[]);

int totalItems = 0;

struct product

{

char id[10]; //product id

char name[50]; //name of product

int quantity; //number of items of product in the inventory

int numSold; //number of items sold

float price; //price of the product

float sales; //total sale

};

void saleProduct(struct product arr[], char[] productId, int soldItems)

{

int index = 0;

while(strcmp(arr[index].id, productId) != 0) //getting the index of product same as productId

index++;

arr[index].qunatity -= soldItems;

arr[index].sales += (soldItems*arr[index].price);

}

void displayProductWithZeroQuantity(struct product arr[])

{

int x = 0;

printf("Zero Quantity Product:");

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

if(arr[i].qunatity == 0)

{

printf("Id=>%s\tName=>%s\tQuantity=>%d\tNumSold=>%.2f\tPrice=>%d\tSales=>%.2f", &arr[i].id, &arr[i].name, &arr[i].quantity, &arr[i].numSold, &arr[i].price, &arr[i].sales);

x = 1;

}

if(x == 0)

printf("No product with zero quantity.");

}

void displayHighestSaleProduct(struct product arr[])

{

float max = 0.0f;

int index = 0;

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

if(arr[i].sales > max)

{

max = arr[i].sales;

index = i;

}

printf("Highest saling product:");

printf("Id=>%s\tName=>%s\tQuantity=>%d\tNumSold=>%.2f\tPrice=>%d\tSales=>%.2f", &arr[index].id, &arr[index].name, &arr[index].quantity, &arr[index].numSold, &arr[index].price, &arr[index].sales);

}

void display(struct product arr[])

{

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

{

printf("Id=>%s\tName=>%s\tQuantity=>%d\tNumSold=>%.2f\tPrice=>%d\tSales=>%.2f", &arr[i].id, &arr[i].name, &arr[i].quantity, &arr[i].numSold, &arr[i].price, &arr[i].sales);

printf("\n");

}

}

void editProduct(struct product arr[], int incrementKey, char productId[])

{

int index = 0;

while(strcmp(arr[index].id, productId) != 0) //getting the index of product same as productId

index++;

arr[index].quantity += incrementKey ;

}

void addProduct(struct product arr[], struct product p)

{

int index = 0;

while(index < totalItems)

index++;

arr[index] = p;

totalItems++;

}

void deleteProduct(struct product arr[], char[] productId)

{

int index = 0;

while(strcmp(arr[index].id, productId) != 0) //getting the index of product same as productId

index++;

for(int i = index;i<totalItems-1;i++)

arr[i] = arr[i+1] ;

totalItems--;

}

void processintChoice(int x, struct product arr)

{

switch(x)

{

case 1:

{

char id[10];

char name[50];

int quantity;

float price;

printf("\nenter the id of product:");

scanf("%s", &id);

printf("\nenter the name of product:");

scanf("%s", &name);

printf("\nenter the quantity of product:");

scanf("%d", &quantity);

printf("\nenter the price of product:");

scanf("%.2f", &price );

struct product p;

p.id = id;

p.name = name;

p.quantity = quantity;

p.price = price;

p.numSold = 0;

p.sales = 0.0f;

addProduct(arr, p);

}

case 2:

{

char str[10];

int num;

printf("enter the product id");

scanf("\n%s", &str);

printf("enter the number by which you want to increase product items.")

scanf("\n%d", &num);

editProduct(arr, num ,str);

}

case 3:

{

char p[10];

printf("enter the product id to delete product:");

scanf("\n%s", &p);

deleteProduct(arr, p);

}

case 4:

{

display(arr);

}

case 5:

{

char p[10];

int num;

printf("enter the product od to purchse:");

scanf("\n%s", &p);

printf("enter the number of items u want to purchse:");

scanf("\n%d", &num);

saleProduct(arr, p, num);

}

case 6:

{

displayHighestSaleProduct(arr);

}

case 7:

{

displayProductWithZeroQuantity(arr);

}

case 8:

{

exit(0);

}

}

}

int main()

{

struct product arr[MAX_SIZE];

char pass[10];

printf("please enter the password:")

scanf("\n%s", &pass);

if(strcmp(pass, password) == 0)

{

label:

printf("\nplease select the proper option from the below menu:");

printf("\n1.) Input new product record");

printf("\n2.) Edit a product");

printf("\n3.) delete a product");

printf("\n4.) display all existing products");

printf("\n5.) make a purchase");

printf("\n6.) display the product detail with highest sale");

printf("\n7.) display a product with zero quantity");

printf("\n8.) exit the program");

int choice;

printf("\nChoice - >");

scanf("%d", &choice);

if(choice < 1 && choice > 8 )

{

printf("Invalid Choice! please choose again");

goto label;

}

else

processChoice(choice, arr);

}

else return(0);

}

3 0
3 years ago
Manipulating an experiment so that you get desired data in research is an example of​
andrew11 [14]
Influencing independent variable(s)
4 0
2 years ago
Other questions:
  • What is the magnitude of the largest positive value you can place in a bool? a char? an int? a float?
    14·1 answer
  • Nadia would like to find text in her current document that differentiates CompanyABC from companyabc. Which option should she us
    8·2 answers
  • A user complains that his computer automatically reboots after a short period of time. Which of the following computer component
    13·1 answer
  • Your wireless network has been breached and it seems as though the attacker has modified a portion of your data that is used wit
    12·1 answer
  • You've been given a network of 130.0.0.0 /16. you need to divide it into four VLSM subnets as follows:
    8·1 answer
  • 3. State whether the given statements are true or false. a. The computer is called a data processor because it can store, proces
    13·1 answer
  • Describe all the main stress causal agents​
    10·1 answer
  • I'm showing my friends brainly. Answer with anything so they can see how fast I can get answers.
    10·2 answers
  • What is one of the advantages of using an algorithm to solve a puzzle like Kriss-Kross or Sudoku?
    13·1 answer
  • What is Utility Software ? Name any two utility programs. <br>​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!