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
sergij07 [2.7K]
3 years ago
11

Consider the following C program: int fun(int *i) { *i += 5; return 4; } 352 Chapter 7 Expressions and Assignment Statements voi

d main() { int x = 3; x = x + fun(&x); } What is the value of x after the assignment statement in main, assuming a. operands are evaluated left to right. b. operands are evaluated right to left
Computers and Technology
1 answer:
Musya8 [376]3 years ago
4 0

Answer:

a. operands are evaluated left toright. 7

b. operands are evaluated right toleft. 12

Explanation:

a. operands are evaluated left toright. 7

b. operands are evaluated right toleft. 12

left to right

int fun (int *i) {

*i +=5; we add 5to x making x 8

return4; we return 4 tomain

}

void main ( ) {

int x = 3;

x = x + fun(&x); x starts at 3 in fun it ischanged to 8 but the 3 is already being used the 4 fromfun is added (3+4) to it making it 7

}

right toleft x starts at 3 in fun x gets changed to 8 and fun is returned as 4so we have 4 + 8 = 12

Paraphrasing

left to right it's is 3 + 4 =7 original value of x is used

right to left it is 4 + 8 =12 x is used as it was changed by fun, since fun was alreadyexecuted

You might be interested in
Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a con
Sophie [7]

Answer:

Explanation:

The following code is written in Java. It creates the three classes as requested with the correct constructors, and getter/setter methods. Then the test class asks the user for all the information and creates the customer object, finally printing out that information from the object getter methods.

import java.util.Scanner;

class Person {

   String name, address, telephone;

   private void Person (String name, String address, String telephone) {

       this.name = name;

       this.address = address;

       this.telephone = telephone;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public String getAddress() {

       return address;

   }

   public void setAddress(String address) {

       this.address = address;

   }

   public String getTelephone() {

       return telephone;

   }

   public void setTelephone(String telephone) {

       this.telephone = telephone;

   }

}

class Customer extends Person {

   String customerNumber;

   Boolean mailingList;

   public Customer(String s, Boolean mail) {

       super();

       this.customerNumber = customerNumber;

       this.mailingList = mailingList;

   }

   public String getCustomerNumber() {

       return customerNumber;

   }

   public void setCustomerNumber(String customerNumber) {

       this.customerNumber = customerNumber;

   }

   public Boolean getMailingList() {

       return mailingList;

   }

   public void setMailingList(Boolean mailingList) {

       this.mailingList = mailingList;

   }

}

class Test {

   public static void main(final String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Customer Name: ");

       String name = in.nextLine();

       System.out.println("Enter Customer Address: ");

       String address = in.nextLine();

       System.out.println("Enter Customer Telephone: ");

       String telephone = in.nextLine();

       System.out.println("Would you like to receive mail? y/n ");

       Boolean mail;

       if(in.nextLine() == "y") {

           mail = true;

       } else {

           mail = false;

       }

       Customer customer = new Customer("1", mail);

       customer.setName(name);

       customer.setAddress(address);

       customer.setTelephone(telephone);

       System.out.println("Name: " + customer.getName());

       System.out.println("Address: " + customer.getAddress());

       System.out.println("Telephone: " + customer.getTelephone());

       System.out.println("Wants to receive mail: " + String.valueOf(customer.getMailingList()));

   }

}

7 0
3 years ago
WILL GIVE BRAINLIEST!!!!!!!
lisov135 [29]

Answer:

Ac

Explanation:

Ac maybe.Idk sorry.

8 0
3 years ago
A manufacturing company produces products. The following product information is stored: product name, product ID and quantity on
denis23 [38]

Answer:

b

Explanation:

took the test a while back

8 0
3 years ago
Write a program that takes a positive integer argument N, and prints out the average, minimum, and maximum (in that order) of N
Flura [38]

Answer:

from random import seed, choices

from statistics import mean

number = int(input("Enter integer number: "))

if number > 0:

   try:

       data = range(number+1)

       # to generate a pseudo-random number list.

       seed(10)

       # you can also use: num_list = [random.randint(0, number+1) for i in data]

       num_list = choices(data, k=len(data))

       print(num_list)

       mean_val = round(mean(num_list), 2)

       min_val = min(num_list)

       max_val = max(num_list)

   except ValueError:

       print("Must be an integer value.")

print('Avg number: {}\nMax number: {}\nMin number: {}'.format(mean_val, max_val, min_val))

Explanation:

To generate random items in a list of integers, the random choices method is used and a sequence is passed as an argument. The average, maximum, and minimum number of the list is calculated and displayed.

7 0
3 years ago
How many bytes in 1 Mbps
Elan Coil [88]
1 Megabyte= 1000 Kilobytes
7 0
3 years ago
Read 2 more answers
Other questions:
  • Which process is used to protect transmitted data in a vpn?
    12·1 answer
  • Anna is making a presentation on the solar system. She wants to emphasize the planet names as they appear one by one on the pres
    11·1 answer
  • By placing the chorale melody in the highest voice and using a simple harmonization, bach made it easier for congregation member
    5·1 answer
  • Which task is a part of the analysis phase of the SDLC
    9·2 answers
  • Who plays Roblox and wants to be friends on it
    9·2 answers
  • hello my friend is doing a give away at 100 followers would you follow him for a chance to win 2000 vbucks his name is ZoVa_Velo
    15·2 answers
  • Problem statement: Using loop, write a program that will ask the user to enter a character for left or right. Then, the user wil
    13·1 answer
  • Sequential codes may be used to represent complex items or events involving two or more pieces of related data.
    7·1 answer
  • Match each with the correct answer.
    7·1 answer
  • Which of the following can be termed ‘application software’?​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!