Successfully reported this slideshow.
Your SlideShare is downloading. ×

Please write in C Clunker Motors Inc- is recalling all vehicles in its.docx

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 2 Ad

Please write in C Clunker Motors Inc- is recalling all vehicles in its.docx

Download to read offline

Please write in C
Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002. Given an int variable modelYear and an array of chars representing a string modelName write a statement that prints the message \"RECALL\" to standard output if the values of modelYear and modelName match the recall details.
Solution
Recall.c
#include <stdio.h>
#include<string.h>
int main()
{
int modelYear;
char modelName[50];
printf(\"Please enter model name :\ \");
gets(modelName);
printf(\"Please enter modelYear \ \");
scanf(\"%d\", &modelYear);
if ((strcmp(modelName, \"Extravagant\") == 0) && modelYear >= 1999 && modelYear <= 2002){
printf(\"\ RECALL\ \");
}
return 0;
}
Output:
Please enter model name :
Extravagant
Please enter modelYear
2000
RECALL
.

Please write in C
Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002. Given an int variable modelYear and an array of chars representing a string modelName write a statement that prints the message \"RECALL\" to standard output if the values of modelYear and modelName match the recall details.
Solution
Recall.c
#include <stdio.h>
#include<string.h>
int main()
{
int modelYear;
char modelName[50];
printf(\"Please enter model name :\ \");
gets(modelName);
printf(\"Please enter modelYear \ \");
scanf(\"%d\", &modelYear);
if ((strcmp(modelName, \"Extravagant\") == 0) && modelYear >= 1999 && modelYear <= 2002){
printf(\"\ RECALL\ \");
}
return 0;
}
Output:
Please enter model name :
Extravagant
Please enter modelYear
2000
RECALL
.

Advertisement
Advertisement

More Related Content

More from helenc18 (20)

Recently uploaded (20)

Advertisement

Please write in C Clunker Motors Inc- is recalling all vehicles in its.docx

  1. 1. Please write in C Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002. Given an int variable modelYear and an array of chars representing a string modelName write a statement that prints the message "RECALL" to standard output if the values of modelYear and modelName match the recall details. Solution Recall.c #include <stdio.h> #include<string.h> int main() { int modelYear; char modelName[50]; printf("Please enter model name : "); gets(modelName); printf("Please enter modelYear "); scanf("%d", &modelYear); if ((strcmp(modelName, "Extravagant") == 0) && modelYear >= 1999 && modelYear <= 2002){ printf(" RECALL "); } return 0; } Output: Please enter model name : Extravagant Please enter modelYear 2000
  2. 2. RECALL

×