Advertisement
Guest User

Application 1 INSAT MPI ( programmation C )

a guest
Sep 21st, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.21 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5.  
  6. void main() {
  7.  
  8.     // vars
  9.  
  10.     char ch1[50],ch2[50],ch3[50];
  11.  
  12.     // getting chars
  13.  
  14.     puts("gimme ch1 \n");
  15.     gets(ch1);
  16.     puts("gimme ch2 \n");
  17.     gets(ch2);
  18.  
  19.     // ops
  20.  
  21.     printf("ch1 is equal to \" %s \" \n",ch1);
  22.     printf("ch2 is equal to  \" %s \" \n",ch2);
  23.  
  24.     // comp
  25.  
  26.     int comp;
  27.  
  28.     comp = strcmp(ch1,ch2);
  29.  
  30.     switch(comp) {
  31.  
  32.         case 0: printf("ch1 = ch2 \n"); break;
  33.         case 1: printf("ch1 > ch2 \n"); break;
  34.         case -1: printf("ch1 < ch2 \n"); break;
  35.         default: printf("WTF !! \n"); break;
  36.     }
  37.  
  38.  
  39.      // concatination
  40.  
  41.      strcpy(ch3,ch1);
  42.  
  43.      strcat(ch3,ch2);
  44.  
  45.      printf("ch1 + ch2 = '%s' \n", ch3);
  46.  
  47.      // num values
  48.  
  49.      printf(" the numeric values of ch1 and 2 are %d and %d \n",atoi(ch1),atoi(ch2));
  50.  
  51.      // identification
  52.  
  53.     printf(" ch1 is upper ? %d \n",isupper(ch1[0]));
  54.     printf(" ch2 is upper ? %d \n",isupper(ch2[0]));
  55.  
  56.  
  57.     printf(" ch1 is lower ? %d \n",islower(ch1[0]));
  58.     printf(" ch2 is lower ? %d \n",islower(ch2[0]));
  59.  
  60.     printf(" ch1 is decimal ? %d \n",isdigit(ch1[0]));
  61.     printf(" ch2 is decimal ? %d \n",isdigit(ch2[0]));
  62.  
  63.     printf(" ch1 is space ? %d \n",isspace(ch1[0]));
  64.     printf(" ch1 is space ? %d \n",isspace(ch1[0]));
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement