Advertisement
M1RAI

solution_ex4

Feb 26th, 2021
975
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include <stdlib.h>
  4. void main()
  5. {
  6.     char ch1[30],ch1n[30];
  7.     char ch2[30],ch2n[30];
  8.     int k,i;
  9.     printf("ch1=");
  10.     scanf("%s",&ch1);
  11.     printf("\n ch2=");
  12.     scanf("%s",&ch2);
  13.     k=0;
  14.     ch1n[0] = '\0';
  15.     for(i=0;i<strlen(ch1);i++)
  16.     {
  17.         if(ch1[i]>='0' && ch1[i]<='9')
  18.         {
  19.             ch1n[k]=ch1[i];
  20.             k++;
  21.         }
  22.     }
  23.     k=0;
  24.     ch2n[0] = '\0';
  25.     for(i=0;i<strlen(ch2);i++)
  26.     {
  27.         if(ch2[i]>='0' && ch2[i]<='9')
  28.         {
  29.             ch2n[k]=ch2[i];
  30.             k++;
  31.         }
  32.  
  33.     }
  34.     printf("la somme des chiffres dans le deux chaines est: %d",atoi(ch1n)+atoi(ch2n));
  35.     system("pause");
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement