Toggle the character

 /* stdin is input standard input

*/


#include <stdio.h>

#include <stdlib.h>


#define SIZE 30


int main (){

char text[SIZE];

int index;

printf("please enter the string Value\n");

fgets(text, SIZE, stdin);

printf("enter string is %s \n", text);

for(index = 0; text[index] != '\0'; index++)

{

    if(text[index] >= 'A' && text[index] <= 'Z' )

    text[index]=text[index]+32;

    else if (text[index] >= 'a' && text[index] <= 'z' )

    text[index]=text[index]-32;

}printf("string value after toggle is %s\n", text);


return 0 ;

}

Comments

Popular posts from this blog

Factors : using C

Cross shaped pattern

Factorial ! calculation