bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

assignment-s-08.c (1171B)


      1 /*
      2  * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025
      3  * Repo: https://github.com/notamitgamer/bsc
      4  * License: MIT
      5  */
      6 
      7 /* Write a program that counts the number of occurrences of each alphabet (A-Z, a-z) in
      8 the text entered using Command-Line Arguments. */
      9 
     10 #include <stdio.h>
     11 #include <string.h>
     12 
     13 int main(int argc, char *argv[])
     14 {
     15     int target[2], i, j, count[2], len;
     16     for (target[0] = 'A', target[1] = 'a'; target[0] <= 'Z', target[1] <= 'z'; target[0]++, target[1]++)
     17     {
     18         count[0] = 0;
     19         count[1] = 0;
     20         for (i = 1; i < argc; i++)
     21         {
     22             len = strlen(argv[i]);
     23             for (j = 0; j < len; j++)
     24             {
     25                 if (argv[i][j] == target[0])
     26                 {
     27                     count[0]++;
     28                 }
     29                 if (argv[i][j] == target[1])
     30                 {
     31                     count[1]++;
     32                 }
     33             }
     34         }
     35         if (count[0])
     36         {
     37             printf("\n\"%c\" found %d times.", target[0], count[0]);
     38         }
     39         if (count[1])
     40         {
     41             printf("\n\"%c\" found %d times.", target[1], count[1]);
     42         }
     43     }
     44     return 0;
     45 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror