Wednesday, June 3, 2015

Importance Programming Tutorial

Check weather the string is palindrome or not.( with using string library function)

 #include<Stdio.h>
#include<conio.h>
                Main ()
{
                Char a[50] , b[50];
                Printf(“entry a string”);
                Gets(a);
                Strcpy(b,a);
                Strev(b);
                If (strcmp (a,b)==0)
                Printf(“ the sting is palindrome”);
                Else
                Printf(“in the string is not palindrome”);
                Getch();
                }



Write a program to read a string & count number of upper case letter , lower case latter, digits & special symbol.

 #include<Stdio.h>
#include<conio.h>
                Main()
{             
                Int len, I , countup=o , countlo=o, countdi=o, countsp=o;
                Char a [50];
                Printf(“enter a string”);
                Gets(a);
                Len= strlen (a);
                For (i=0; i<len; i++)
                {
                If (a[i] >= ‘A’ && a[i]<=’2’)
                Countlo = countlo + 1;
                Else if (a[i] >= ‘A’ && a[i]<=’Z’)
                Countup= countdi + 1;
                Else if (a[i]>=’O’ && a[i]<=’9’)
                Countdi= countdi + 1;
                Else
                Countsp= countsp + 1;
                }
Printf(“in no. of uppercase alphabet % d”, countup);
Printf(“in no. of lowercase alphabet % d”, countlo);
Printf(“in no. of digits % d”, countdi);
Printf(“in no. of special symbol % d”, countsp);





Write a program to read a string & convert upper case alphabet to lower case & lower case to upper case.


 #include<Stdio.h>
#include<conio.h>
                Main ()
{
                Int len, I;
                Char a [50];
                Printf(“enter a string);
                Gets(a);
                Len= strlen (a);
                For (i=0; i<len; i++)
                {
                If (a[i] >= ‘A’ && a[i]<=’Z’)
                a[i]= toupper (a[i]);
                else if( a[i]>= ‘A’ &&  a[i]<= ‘2’);
                a[i]= tolower(a[i]);
                }
                Print(“The changed string is %”, a);
}

No comments:

Post a Comment