ivana_andreevska

Untitled

May 21st, 2021
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. Да се напише програма која за дадена текстуална датотека text.txt ќе го одреди и отпечати на екран односот на самогласките и согласките.
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6.  
  7. int eSamoglaska(char curr)
  8. {
  9.     return curr=='a' || curr=='e' || curr=='i' || curr=='o' || curr=='u';
  10. }
  11.  
  12. int main()
  13. {
  14.     FILE *p=fopen("1.txt" , "r");
  15.  
  16.     char curr;
  17.  
  18.     int brojacSamoglaski=0;
  19.     int brojacSoglaski=0;
  20.  
  21.     while((curr=fgetc(p))!=EOF)
  22.     {
  23.      if(isalpha(curr))
  24.      {
  25.          if(eSamoglaska(curr))
  26.             ++brojacSamoglaski;
  27.          else
  28.             brojacSoglaski++;
  29.      }
  30.     }
  31.  
  32.     printf("Soodnos na samoglaski/soglaski e %.2f",brojacSamoglaski*1.0/brojacSoglaski);
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment