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
Katena32 [7]
3 years ago
5

For the following code, if the input is negative, make numitemsPointer be null. Otherwise, make numitemsPointer point to numitem

s and multiply the value to which numitems Pointer points by 10.
Ex: If the user enters 99, the output should be: Items: 990
Code :
#include
int main(void) {
int* numItemsPointer;
int numItems;
scanf ("%d", &numItems);

/* Your solution goes here */

if (numItems Pointer == NULL) {
printf ("Items is negative\n");
}
else { printf("Items: %d\n", *numItemsPointer);
}
return 0;
}
Computers and Technology
2 answers:
weeeeeb [17]3 years ago
7 0

Answer:

The program to this question can be described as follows:

Program:

#include <stdio.h> //defining header file  

int main() //defining main method

{

int* numItemsPointer; //defining pointer variable

int numItems; //defining integer variable

scanf ("%d", &numItems); //input value from user end

if(numItems < 0) //defining if block to check value

{

   numItemsPointer = NULL; //assign value to null

   printf ("Items is negative\n"); //print message

}

else //else block

{

   numItemsPointer = &numItems; //holds address

   numItems = numItems * 10; //multiple by 10

   printf("Items: %d\n", *numItemsPointer); //print value

}

return 0;

}

Output:

99

Items: 990

Explanation:

In the above program two integer variable "numItemsPointer and numItems" is defined, in which numItemsPointer is a pointer variable and numItems is integer variable, in which we input value from the user end, and an if condition statement is used, that check and calculate the values, which can be described as follows:

  • In the if block a condition is defined that variable "numItems" is less then 0, if this condition is true so, inside the block, it will assign a value, that is equal to "NULL", and prints its value.
  • If the condition is not true it will go to the else block, in this block, it will first pointer variable holds the variable address, and multiply the value by 10, and prints pointer variable value.
77julia77 [94]3 years ago
3 0

Answer:

hi

Explanation:

You might be interested in
What single awk command can be used to display all the login names and their associated numerical user IDs
Luden [163]

Answer:

Used the command syntax; awk -F":" '{ print "username: " $<number location> "\t\tuid:" $<number location> }' <target folder>

Explanation:

Linux operating system is a fast open-source computer platform for programmers and network administrators. Its system is arranged in a hierarchical tree structure with the root represented as "/" (for absolute path).

The passwd is a folder in the Linux OS that holds the login details of all users in the system network. The 'awk' is one of the commands used to get information from a file in a folder. It prints out the result by specifying the location of the values (like the username and user id) as a variable (with prefix '$') and then the target folder.

8 0
3 years ago
I will give the brainly or whatever its called
igomit [66]

Answer:

Just answer everyones questions and youll be at the right rank in no time

Explanation:

5 0
2 years ago
Read 2 more answers
The Zootopia Police Department is recruiting new officers and has come up with an innovative equation to hire. They define hireS
Dahasolnce [82]

Answer:

#include<iostream>

#include<limits>

#include<iomanip>

using namespace std;

//function that returns true

//if there is invalid input like giving string as input

// for integer value.

bool isInvalidInput()

{

  //return true if cin.fail

  if(cin.fail())

  {

      //clear the buffer

      cin.clear();

      cin.ignore(numeric_limits<streamsize>::max(),'\n');

      return true;

  }

  return false;

}

//function that calculates the hire score for given 3 parameters.

double calHireScore(double agility,double strength,double speed)

{

  return (1.8*agility) + (2.16 * strength) + (3.24 * speed);

}

//calculate hire score for fox.

void calFoxHireScore()

{

  double agility,strength;

 

  cout<<"Enter Agility Value: ";

  //get agility as input and validate it.

  cin >> agility;

  if(isInvalidInput() || agility <= 0)

  {

      cout<<"\nError: Agility value must be > 0"<<endl;

      return;

  }

 

  cout<<"Enter Strength Value: ";

  cin >> strength;

  if(isInvalidInput() || strength <= 0)

  {

      cout<<"\nError: Strength value must be > 0"<<endl;

      return;

  }

 

  cout<<"\nHire Score for Fox: "<<calHireScore(agility,strength,0)<<endl;

}

//function that asks input from user for

//calculating hire score for Sloth.

void calSlothHireScore()

{

  double strength,speed;

 

  cout<<"Enter Strength Value: ";

  cin >> strength;

  if(isInvalidInput() || strength <= 0)

  {

      cout<<"\nError: Strength value must be > 0"<<endl;

      return;

  }

 

  cout<<"Enter Speed Value: ";

  cin >> speed;

  if(isInvalidInput() || speed <= 0)

  {

      cout<<"\nError: Speed value must be > 0"<<endl;

      return;

  }

 

  cout<<"\nHire Score for Sloth: "<<calHireScore(0,strength,speed)<<endl;

}

//function that asks input from user for

//calculating hire score for Bunny.

void calBunnyHireScore()

{

  double agility,speed;

 

  cout<<"Enter Agility Value: ";

  cin >> agility;

  if(isInvalidInput() || agility <= 0)

  {

      cout<<"\nError: Agility value must be > 0"<<endl;

      return;

  }

 

  cout<<"Enter Speed Value: ";

  cin >> speed;

  if(isInvalidInput() || speed <= 0)

  {

      cout<<"\nError: Speed value must be > 0"<<endl;

      return;

  }

 

  cout<<"\nHire Score for Bunny: "<<calHireScore(agility,0,speed)<<endl;

}

//function to display menu for user.

void menu()

{

  cout<<"\n1. Fox"<<endl;

  cout<<"2. Bunny"<<endl;

  cout<<"3. Sloth"<<endl;

  cout<<"0. Quit"<<endl;

  cout<<"Enter your choice: ";

}

//main method

int main()

{

  int choice;

  do

  {

      //asks choice

      menu();

      cin >> choice;

      //if invalid input print erro message

      if(isInvalidInput())

      {

          cout<<"\nError: Invalid choice enetered. Try Again\n";

      }

      else

      {

          cout<<"\n";

          //if any one of the choices do accordingly

          //for invalid choice print error mesage.

          switch(choice)

          {

              case 1:

                  calFoxHireScore();

                  break;

              case 2:

                  calBunnyHireScore();

                  break;

              case 3:

                  calSlothHireScore();

                  break;

              case 0:

                  cout<<"\nQutting...\n";

                  break;

              default:

                  cout<<"Invalid choice entered."<<endl;

                  break;

          }

      }

     

  }while(choice != 0);

 

  return 0;

}

Explanation:

3 0
3 years ago
Adding _____ will allow the user to create text as it will often appear in publications with multiple articles, such as a newspa
mart [117]
Does applications make sense <span />
5 0
3 years ago
Read 2 more answers
Select the phrases that apply to Java classes or methods.
oee [108]

Answer:

graficar una lista de entradas

graficar una lista de entradas

crear un nuevo objeto

condiciones de prueba

romper un ciclo

romper un ciclo

Explanation:

7 0
2 years ago
Other questions:
  • A typical, small, dry cell battery has a voltage of A. 6.0 volts. B. 1.0 volts. C. 12.0 volts. D. 1.5 volts.
    11·2 answers
  • John is considering his STEM education choices. He wants to begin working in the technology field as soon as possible.
    12·1 answer
  • Relation between training and occupation with examples in points . Plz tell fast<br> ​
    5·1 answer
  • Drag the correct type of update to its definition.
    13·1 answer
  • What is the most significant issue that needs to be addressed when ensuring the proper functioning of a computer?
    7·1 answer
  • You can invoke or call a method from another program or method. When methods must share data, you can pass the data into and ret
    6·1 answer
  • Assume that sentence is a variable that has been associated with a string consisting of words separated by single space characte
    12·2 answers
  • An end-user license agreement protects _____.
    7·1 answer
  • The average pH of citrus fruits is 2.2, and this value has been stored in the variable avg_citrus_pH . Provide a statement to di
    15·1 answer
  • explain the joke, “There are 10 types of people in the world: those who understand binary and those who don’t.”
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!