M1RAI

solution_ex4

Feb 26th, 2021
846
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×