Thursday, 12 January 2012

Write a program that inputs several lines of text (such as a paragraph or a poem), then counts the number of times the letter‘d’ of the alphabet


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>

int main()
{
    char a[100];
    cout << "Enter a string : ";
    cin.get(a,99,'+');

    int count=0;

    for(int j=0; j<100; j++)
        if( a[j]=='d' || a[j]=='D' )
            count++;


    cout << "\n The Number of Times the Letter'd' of Alphabet appeared is : "  << count;

    getche();
    return 0;
}

No comments:

Post a Comment