answer.
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
STatiana
1 month 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:
Harlamova29_29 [932]1 month ago
7 0

Answer:

The solution for the given question can be outlined as follows:

Program:

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

int main() // declare the main function

{

int* numItemsPointer; // declare a pointer for integer

int numItems; // declare an integer variable

scanf ("%d", &numItems); // receive user input

if(numItems < 0) // check if the input value is negative

{

numItemsPointer = NULL; // set pointer to null

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

}

else // if the condition is false

{

numItemsPointer = &numItems; // point to the address of numItems

numItems = numItems * 10; // multiply numItems by 10

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

}

return 0;

}

Output:

99

Items: 990

Explanation:

The program defines two integer variables, "numItemsPointer" as a pointer and "numItems" as an integer. The user inputs a value which is checked through an if statement to calculate results, detailed as follows:

  • In the if condition, if "numItems" is less than 0, it sets its value to "NULL" and prints an appropriate message.
  • If the condition is false, it transfers the address of "numItems" to the pointer and then multiplies "numItems" by 10 before printing the value held by the pointer.
Rzqust [894]1 month ago
3 0

Answer:

hello

Explanation:

You might be interested in
An Internet user has a need to send private data to another user. Which of the following provides the most security when transmi
ivann1987 [930]

Response:

C. Utilizing public-key encryption for data transfer

Reasoning:

Only encryption offers a secure method for communication.

4 0
1 month ago
Read 2 more answers
Xem tập các tiến trình sau đây, với thời gian cần chạy ở cột Burst Time được cho ở đơn vị mili giây.
maria [879]
I can't comprehend this language; otherwise, I would assist you.
3 0
18 days ago
Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input.
Amiraneli [921]

Answer:

In C++:

#include <iostream>

#include <string>

#include <sstream>

using namespace std;

int main(){

   string lname, fname, stringnum;    int num; string login, pwd;

   cout<<"Last Name: ";    cin>>lname;

   cout<<"First Name: ";    cin>>fname;

   cout<<"Four-digit integer: ";    cin>>num;

   stringnum = to_string(num).substr(0, 4);

   stringstream geek(stringnum);    geek>>num;

   num = num%100;

   pwd = to_string(num);

   if(lname.length()<5){ login = lname + fname.substr(0, 1);    }

   else{ login = lname.substr(0, 5) + fname.substr(0, 1);    }

   cout<<"Login Name: "<<login<<endl;

   cout<<"Password: "<<pwd<<endl;

   return 0;

}

Explanation:

This initializes all the required variables

   string lname, fname, stringnum;    int num;     string login, pwd;

This asks the user for their last name

   cout<<"Last Name: ";    cin>>lname;

This asks for the first name of the user

   cout<<"First Name: ";    cin>>fname;

This prompts for a four-digit number

   cout<<"Four-digit integer: ";    cin>>num;

This converts the number into a string and extracts the first four digits

   stringnum = to_string(num).substr(0, 4);

This changes the string back into an integer

   stringstream geek(stringnum);    geek>>num;

This extracts the last two digits of the four-digit number

   num = num%100;

This generates the user's password

  pwd = to_string(num);

This constructs the user's login name.

This block runs if the last name has fewer than five letters

   if(lname.length()<5){ login = lname + fname.substr(0, 1);    }

This block runs otherwise

   else{ login = lname.substr(0, 5) + fname.substr(0, 1);    }

This displays the login name

   cout<<"Login Name: "<<login<<endl;

This displays the password

   cout<<"Password: "<<pwd<<endl;

3 0
1 month ago
Given positive integer numInsects, write a while loop that prints that number doubled without reaching 200. Follow each number w
zubka84 [945]

Answer:

The code placed where "/*Your solution goes here */" is as follows:

while(numInsects<200) // while loop

       {

            System.out.print(numInsects+" "); // output statement

            numInsects=numInsects*2; // operation to double the value.

       }

Output:

  • If the input is 16, the result is 16 32 64 128.
  • If the input is 25, the result is 25 50 100.

Explanation:

  • The above Java code fills the section designated as "Your solution" and will operate correctly.
  • The program accepts a user input and continues to print double the value until it reaches 200 or more.
  • The while loop evaluates whether the value remains below 200. If so, the operation proceeds; otherwise, it stops.
5 0
1 month ago
Assume a machine during its initial testing phase produces 10 widgets a day. After 10 days of testing (starting on day 11), it b
Harlamova29_29 [932]

Response:

Python Code:

n = int(input("Days: "))

total = 0

for i in range(1,n+1):

     if i <= 10:

           total += 10

     elif i <= 60:

           total += 40

     elif i <= 99:

           total += 100 - i

print(str(total)+ " widgets")

Clarification:

This line requests user input for the number of days.

n = int(input("Days: "))

This line sets the initial total number of widgets to zero.

total = 0

The subsequent loop calculates total widgets based on the established rules.

for i in range(1,n+1):

     if i <= 10: -> Applies when days are 10 or fewer

           total += 10

     elif i <= 60: -> Applies when days are between 11 and 60

           total += 40

     elif i <= 99: -> Applies when days are under 100

           total += 100 - i

This line outputs the total count.

print(str(total)+ " widgets")

4 0
28 days ago
Other questions:
  • . Electricians will sometimes call ______ "disconnects" or a "disconnecting means."
    12·1 answer
  • This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by
    15·1 answer
  • Imagine you were using some of our pixelation tools to create an image and you posted it online for your friends to see - but, a
    11·1 answer
  • Write a loop that reads strings from standard input, where the string is either duck or goose. the loop terminates when goose is
    7·1 answer
  • Consider the following skeletal C program: void fun1(void); /* prototype */ void fun2(void); /* prototype */ void fun3(void); /*
    11·1 answer
  • Form the recurrence relations (RRs) for the number of vertices and the number of edges of a hypercube of n dimensions, Hn. Solve
    13·1 answer
  • 5.15 LAB: Output values below an amount Write a program that first gets a list of integers from input. The input begins with an
    9·2 answers
  • What type of memory can support quad, triple, and dual channels?
    5·1 answer
  • When adopting and implementing a Software as a Service (SaaS) platform such as Salesforce for your business, which responsibilit
    7·1 answer
  • A 2-dimensional 3x3 array of ints, has been created and assigned to tictactoe. Write an expression whose value is true if the el
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!