Created
December 19, 2018 23:48
-
-
Save kainio/e315f30fbd92b40fcc3f9e6494aa236c to your computer and use it in GitHub Desktop.
Afficher le titre et le nom de l'ulitlisateur comme un message de bienvenu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdlib.h> | |
#include<string.h> | |
int main() | |
{ | |
//déclaration des variales de type string | |
char prenom[20]; | |
char titre[10]; | |
//saisire le prenom | |
printf("entrez votre prenom: "); | |
scanf("%s",prenom); | |
//saisir le titre | |
printf("entrez votre titre: "); | |
scanf("%s",titre); | |
//vérifier si le titre donné par l'ustilisateur correspond au titre prédéfinie (comme "Mr") | |
if(strcmp(titre,"Mr") == 0) | |
{ | |
printf("%s %s, soyez le bienvenu", titre,prenom); | |
} else if ((strcmp(titre, "Ms") == 0) || (strcmp(titre, "Mme") == 0)) | |
{ | |
printf("%s %s, soyez la bienvenue", titre,prenom); | |
} else { | |
printf("Titre inconnu"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment