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
Write a C program to implement a command called ​displaycontent ​that takes a (text) file name as argument and display its conte
Zanzabum

Answer:

/*

Student: Hugo Meza

Date: February 15, 2019

Description: This program mimic the cat command from Linux. Checks whether the source file

has the right permissions, and then writes in the console its content.

*/

#include <stdio.h>

#include <fcntl.h>

#include <unistd.h>

#include <errno.h>

int hasPermission(char *filepath){

int returnval;

// Check file existence

returnval = access (filepath, F_OK);

if(errno == ENOENT){

printf ("%s does not exist\n", filepath);

return 0;

}

else if (errno == EACCES){

printf ("%s is not accessible\n", filepath);

return 0;

}

// Check read access

returnval = access (filepath, R_OK);

if(errno == ENOENT){

printf ("%s does not have read access\n", filepath);

return 0;

}

else if (errno == EACCES){

printf ("%s is not accessible\n",filepath);

return 0;

}

// Check write access

returnval = access (filepath, W_OK);

if(errno == ENOENT){

printf ("%s does not have read access\n", filepath);

return 0;

}

else if (errno == EACCES){

printf ("%s is not accessible\n",filepath);

return 0;

}

return 1;

}

int main(int argc, char* argv[]){

if(!argv[1]){

printf("Error. Specify file to open\n");

return 0;

}

int fd;

char *fp = argv[1], content[fd];

if(hasPermission(fp) == 0)

return 1;

fd = open(fp, O_RDONLY);

int bytes = read(fd,content,sizeof(content)-1);

write(1, content, bytes);

close(fd);

return 0;

}

Explanation:

7 0
3 years ago
What is the difference between simple and complex waveforms?
Nataliya [291]
Simple waveform - something like a sine wave. Very pure sound like you used to get on the tv when that girl was sitting with the toys in the middle of the night. Complex waveform is like speech etc
5 0
3 years ago
The two major types of system software programs are utility programs and the ________. Select one: A. user interface B. supervis
Scrat [10]

Answer:

operating system

Explanation:

System software are those programs that many refer to as computer programs. The most basic function of system software is to manage the computer systems. It acts as an interface between the computer’s hardware and the end user. System software converts instructions that end users give to the computer into a machine understandable language. Examples of system software include operating systems, utility programs, device drivers, and windows systems. The operating system is responsible for the functioning of all the computer’s hardware parts. It is the software loaded into the system when the computer boots up. It manages everything, from the memory, to the CPU, and many other different tasks.

8 0
3 years ago
What are the side effects of overclocking?
Oksana_A [137]

Answer:

Reduced processor lifespan, reduced fan cooler performance over time, bugs.

Explanation:

The reason is that when you overclock your processor you are increasing its base speeds in GHZ. The processor was designed to work at a determined speed, let's say 3.00 ghz. If you increase this speed to 4.00 ghz, it's not just that now it's working faster, it also draws more power from your power supply, and increases the heat that the chip is taking. Processors are designed to endure high temperatures, therefore, you will likely not see any damaged in short term, but your components life span will be severely reduced, also depending on how much you overclock the processor, and the stability of your system, you can see bugs, unexpected restarts, and strange behavior of the computer. As an example, the i5 4670k runs at 3.80 stock speed, it can reach 50 / 65 degrees under full load. If you raise the speed up to 4.5ghz it will reach 70/80 degrees, depending on your ambient temperature and other factors.

6 0
2 years ago
How r u<br> ;)<br> happy what day is it
Ivahew [28]

Answer:

o

dw

Explanation:

5 0
2 years ago
Read 2 more answers
Other questions:
  • ?the single most effective security measure for digital devices is to password protect access to them.
    5·1 answer
  • Using the bitwise AND operation, the result of 1 AND 0 is ___________. 10100100 ___________ 11010101 = 01110001. A common way to
    15·1 answer
  • Your bluetooth headset is waiting for another bluetooth device to locate its signal. what is this mode known as?'
    8·1 answer
  • What are the three basic classes of application
    14·2 answers
  • Resumen sobre Tailandia​
    10·1 answer
  • What is the missing line of code?
    7·2 answers
  • A system analyst generally needs to have a number of skills. For example, technical and analytical skills are required for this
    7·1 answer
  • Who here has a crush on jk from bts but feels more mature than him
    10·2 answers
  • FoRWarD MaRcH AND hERe We Go MEMbers of the agEncy BaKuGO AHHHHHHHHH-
    10·2 answers
  • Please help……Your friend is taking images from all over the internet without giving credit to the sources. He tells you that it’
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!