Thread: Need help with small program

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    22

    Question Need help with small program

    Hello all,
    I've been trying to solve a problem here but I'm not able to get the concept right. Please help me out.
    Here is the question and the answer is written below.

    Q. Write a computer program to tabulate the total occurances of
    each of the alphabets A to Z in a string. Allocate a large
    array of 100 or more characters for the input. Use gets function
    get a string.

    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<string.h>
    int main()  {
      int a[100],i, b[100],j;
      printf("Enter the sentence:");
      gets(a,100);
      b[26]={97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123}
    
    for(i=0;i<100;i++){
      for(j=0;j<=26;j++){
        if(a[i]==b[j]){
          if(b[j]==97)
            ac++;
          elseif(b[j]==98)
            bc++;
          elseif(b[j]==99)
            cc++;
          elseif(b[j]==100)
            dc++;
          elseif(b[j]==101)
            ec++;
          elseif(b[j]==102)
            fc++;
          elseif(b[j]==103)
            gc++;
          elseif(b[j]==104)
            hc++;   
      getch();
      return 0;
    }
    Thanks in advance
    Last edited by alokrsx; 05-24-2009 at 12:50 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help with small program
    By cjohnman in forum C Programming
    Replies: 11
    Last Post: 04-14-2008, 09:59 AM
  2. Program to reverse a number. small error with it..
    By comproghelp in forum C Programming
    Replies: 8
    Last Post: 11-22-2004, 10:52 AM
  3. Help writing small program
    By guitarhead2000 in forum C++ Programming
    Replies: 2
    Last Post: 10-13-2004, 12:42 PM
  4. A little Help with a small program
    By whtpirate in forum C Programming
    Replies: 7
    Last Post: 06-05-2003, 06:15 PM
  5. Very small program...Whats wrong???
    By SmokingMonkey in forum C++ Programming
    Replies: 4
    Last Post: 05-30-2003, 09:09 PM