Monday, August 29, 2011

c programs


/*******************************************************

 program for string conversion
*********************************************************/

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

//procedure declaration

void conversion(char *);
//*********************************************************
void main()
//*********************************************************
{
char name[10];

clrscr();

printf("enter your name:");
scanf("%s",name);

//function calling

conversion(name);

//printing after conversion

printf("after conversion the name is : %s",name);
getch();
}

// procedure declaration

void conversion( char *str )
{
// while loop

while ( *str != '\0' )
{
//if condition

if( islower ( *str ) )
{
*str = toupper ( *str );

}
else
{
*str = tolower ( *str );
}
*str++;

}
}



No comments:

Post a Comment