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
Marat540 [252]
3 years ago
11

write a C program that declares an integer variable called "favorite_number". The program should then prompt the user to enter t

heir favorite number, and use scanf to read the user's input into favorite_number. Finally, the program should print a message that includes the user's input.
Computers and Technology
1 answer:
Arturiano [62]3 years ago
4 0

Answer:

// here is code in C.

// headers

#include <stdio.h>

// main function

int main(void) {

// variable declaration

int favorite_number;

 // ask user to enter favorite number

printf("enter your favorite number : ");

 // read the number

scanf("%d",&favorite_number);

 // print the message

printf("your favorite number is: %d",favorite_number);

return 0;

}

Explanation:

Declare a variable "favorite_number" of integer type.Ask user to enter favorite number and assign it to favorite_number.Then print the message which include the favorite number.

Output:

enter your favorite number : 77

your favorite number is: 77

You might be interested in
Develop a command sequence would you use to alter the amount of space between the text in a text box and the text box border?.
yanalaym [24]

The use of the Line and Paragraph Spacing command can  help one to alter the amount of space between the text in a text box and the text box border.

<h3>Which command changes line spacing?</h3>

When one click on Home tab, one should click the Line and Paragraph Spacing command, and when one has select the line spacing that one needs, the selected line spacing will alter in the document.

Note that the use of the Line and Paragraph Spacing command can  help one to alter the amount of space between the text in a text box and the text box border.

Learn more about command sequence from

brainly.com/question/13258375

#SPJ1

8 0
2 years ago
Create a lottery game application. Generate three random numbers (see Appendix D for help in doing so), each between 0 and 9. Al
Pachacha [2.7K]

The question is not complete! Here is the complete question and its answer!

Create a lottery game application. Generate three random numbers (see Appendix D for help in doing so), each between 0 and 9. Allow the user to guess three numbers. Compare each of the user’s guesses to the three random numbers and display a message that includes the user’s guess, the randomly determined three-digit number, and the amount of money the user has won as follows:

no matches: 0

any one matching: 10$  

two matching: 1000$  

three matching: 100000$  

Code with Explanation:

#include <iostream>

using namespace std;

int main()

{

int matches=0;

int guess_1, guess_2, guess_3;

int num_1, num_2, num_3;

// get 3 digits from the user

cout<<"Enter first guess digit 0 to 9"<<endl;

cin>>guess_1;

cout<<"Enter second guess digit 0 to 9"<<endl;

cin>>guess_2;

cout<<"Enter third guess digit 0 to 9"<<endl;

cin>>guess_3;

// every time program runs srand() generates new random numbers and rand()%10 makes sure that number is single digit 0 to 9

srand(time(NULL));

num_1=rand()%10;

cout<<"First lottery digit: "<<num_1<<endl;

num_2=rand()%10;

cout<<"Second lottery digit: "<<num_2<<endl;

num_3=rand()%10;

cout<<"Third lottery digit: "<<num_3<<endl;

// store random generated numbers and guess numbers in arrays to compare them

int num[3]= {num_1,num_2,num_3};

int guess[3]={guess_1,guess_2,guess_3};

// compare the arrays to find out how many are matching

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

   {

 for(int j=0; j<3; j++)

 {

  if(num[i]==guess[j])

  {    

   matches = matches + 1;

  }

 }

}

cout << "Total Matches are: " <<matches << endl;

// display reward according to the number of matches

if (matches==0)

cout<<"you won: $0"<<endl;

if (matches==1)

cout<<"you won: $10"<<endl;

if (matches==2)

cout<<"you won: $1000"<<endl;

if (matches==3)

cout<<"you won: $100000"<<endl;

return 0;

}

Output:

Enter first guess digit 0 to 9

7

Enter second guess digit 0 to 9

1

Enter third guess digit 0 to 9

5

First lottery digit: 3

Second lottery digit: 7

Third lottery digit: 2

Total Matches are: 1

You won: $10

Enter first guess digit 0 to 9

7

Enter second guess digit 0 to 9

3

Enter third guess digit 0 to 9

4

First lottery digit: 5

Second lottery digit: 4

Third lottery digit: 7

Total Matches are: 2

You won: $1000

5 0
3 years ago
The OnStar system allows Select one: a. a vehicle owner to initiate a conversation with an OnStar representative. b. the vehicle
Rzqust [24]

Answer:  e) a, b, and c

Explanation: OnStar system is the secondary service that is provided by the General Motor Corporation , who is the parent company of this system.The services like in-vehicle protection, diagnosing issues from distance emergency services, communication services based on subscriptions, turn by turn navigation etc.

Conversation started with OnStar member by vehicle owner is communication service in hands -free way, vehicle sending message to OnStar member after mishap/accident is type of emergency services and OnStar member putting off the gas pedal without the permission of driver of the the vehicle is also a protect service .Thus, all the given options are correct.

6 0
3 years ago
What is the difference between a programming language and natural (every-day) language?
marta [7]

Answer:

Explanation:

Natural languages are used for communication between people and programming languages enable human to interact with machines.

8 0
3 years ago
Suppose that a minus sign in the input indicates pop the stack and write the return value to standard output, and any other stri
Sergio [31]
It’s b just really got to make since an read it right that’s all
7 0
3 years ago
Read 2 more answers
Other questions:
  • What are the coordinates of (3 comma space 8 )relative to the basis open curly brackets space (1 comma space 1 )comma space (0 c
    15·1 answer
  • Inattentional blindness occurs when individuals do not observe certain objects or events because they are focused on something e
    10·2 answers
  • The _______ "represents a set of features that enables the user to inform himself whether a security feature is in operation or
    8·1 answer
  • Which elements are in the Sort dialog box? Check all that apply.
    9·1 answer
  • The method needed to arrange for an object to be notified when a window's close-window button has been clicked is
    6·1 answer
  • Write a program named Deviations.java that creates an array with the deviations from average of another array. The main() method
    8·1 answer
  • What is theory of knowledge?​
    13·1 answer
  • PLEASE HELP WILL GIVE BRAINLIEST!!!’
    15·1 answer
  • How do you select a single cell, a single column, a single
    10·1 answer
  • Do small companies need computers? why?<br>​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!