C programming for changing all capital letters and changing all lower letters -


this code

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h>  char chacap(char n);  int main() {   char ch,a;   printf("enter sentence\n");    while((ch=getchar()) != '\n')   {     chacap(ch);     printf("%c",a);   }   printf(" \n");    return 0; } void chacap(char n) {   if(n >= 'a' && n <='z')       n-=32;  } 

i need

  1. ask user enter sentence
  2. convert sentence capital letters , print
  3. convert sentence lower case letters , print
  4. convert each character if upper lower , vice versa.

i made changing capital letters, couldn't make lower , vice versa.

when made code 2. , 3, getchar() became nothing...

use tolower() function :

  while((ch=getchar()) != '\n')   {     printf("%c", tolower(ch));   } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -