Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

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

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité

Consultez-les par la suite

1 sur 2 Publicité

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

Télécharger pour lire hors ligne

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
.

Publicité
Publicité

Plus De Contenu Connexe

Plus par helenc18 (20)

Plus récents (20)

Publicité

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

×