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
IrinaVladis [17]
3 years ago
12

C programming question:

Computers and Technology
1 answer:
denpristay [2]3 years ago
6 0

Answer:

You should do this:

if (0==strcmp(modelName,"Extravagant") && modelYear >= 1999 && modelYear <= 2002)

printf("%s\n","RECALL");

Explanation:

Lets consider this program and analyze the output.

int main()

{

int modelYear;

char modelName[30];

printf("enter the year");

scanf("%d",&modelYear);

printf("enter the modelname");

scanf("%s",modelName);

if (0==strcmp(modelName,"Extravagant") && modelYear >= 1999 && modelYear <= 2002)

printf("%s\n","RECALL");    }

if (0==strcmp(modelName,"Extravagant") && modelYear >= 1999 && modelYear <= 2002)

This statement has a function strcmp  which is used to compare two strings.

If the user enters Extravagant as model name then this input will be compared by the string stored in modelName i.e. Extravagant, character by character. If the string entered by the user matches the string stored in modelName this means this part of the if condition evaluates to true. 0==strcmp means that both the strings should be equal.

The next part of the if statement checks if the model year entered is greater than or equal to 1999 AND less than or equal to 2002. This means that the model year should be between 1999 and 2002 (inclusive).

&& is the logical operator between both the parts of if statement which means that both should evaluate to true in order to display RECALL.

This is correct way to use because the if (modelName == "Extravagant" && modelYear >= 1999 && modelYear <= 2002)  printf("%s\n","RECALL"); statement will not display RECALL. After entering the model name and model year it will move to the next line and exit.

So in if (0==strcmp(modelName,"Extravagant") && modelYear >= 1999 && modelYear <= 2002)

printf("%s\n","RECALL"); statement when the if condition evaluates to true, then RECALL is displayed in the output.

You might be interested in
Reference variables allow arguments to be passed by ____________.
son4ous [18]

Answer:

Reference

Explanation:

The Reference type variable is such type of variable in C# that holds the reference of memory address instead of value. Examples for reference type are classes, interfaces, delegates and arrays.

We can pass parameters to the method by reference using <em>ref </em>keyword

It’s mandatory to initialize the variable value before we pass it as an argument to the method in c#

For example,

int x = 10;  // Variable need to be initialized

Add(ref x); // method call

If you pass parameters by reference in method definition, any changes made to it affect the other variable in method call.

Here's a sample program:

using System;

namespace ConsoleApplication

{

   public class Test

   {

       public static void Main()

       {

           int i = 10;

           Console.WriteLine("i=" + i);

           Add(ref i);

           Console.WriteLine("i=" + i);

           Console.ReadLine();

       }

       public static void Add( ref int j)

       {

           j = j + 10;

           Console.WriteLine("j="+j);

       }

   }

}

Output:

i=10

j=20

i=20

7 0
3 years ago
What is BINARY it is making get confused
enot [183]
It is a number that is expressed in the binary numerical system
6 0
3 years ago
How do you draw first angle of orthographic projection ​
attashe74 [19]
Https://technologystudent.com/designpro/ortho1.htm
5 0
3 years ago
You are most likely to automatically encode information about
Orlov [11]

Answer:

You are most likely to automatically encode information about the sequence of your day's events.

5 0
3 years ago
When activated, an Excel object has all the features of an Excel
Rainbow [258]
D. Workbook
Hope this helps
7 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following statements about the FAFSA process are TRUE?
    6·1 answer
  • You can create a database using one of the many templates available or by creating a new ______ database.
    9·1 answer
  • Overlay analysis is ____________, taking in data from two or more layers to create a single output layer.
    5·1 answer
  • What is a programming language?
    11·1 answer
  • Write a SELECT statement that uses an aggregate window function to get the total amount of each order. Return these columns: The
    13·1 answer
  • PLEASE HELP!!!!!!!!!
    8·1 answer
  • The security administrator for Corp.com wants to provide wireless access for employees as well as guests. Multiple wireless acce
    11·1 answer
  • L00000000000000000000000000000000000000000000000000000000l they b00ty tickled
    6·2 answers
  • This is using python.
    5·2 answers
  • A. Get a value for x from the user.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!