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.