C program to read an English sentence and replace lowercase characters by uppercase and vice-versa. Output the given sentence as well as the case converted sentence on two different lines.

by Nideesh C on April 12, 2011 · 0 comments

in C Programming




/* C program to read an English sentence and replace lowercase characters by uppercase and vice-versa. Output the given sentence as well as the case converted sentence on two different lines. */

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

void main()
{
char sentence[100];
int count, ch, i;

clrscr();

printf(“Enter a sentence\n”);
for(i=0; (sentence[i] = getchar())!=’\n’; i++)
{
;
}

sentence[i]=’\0′;

count = i; /*shows the number of chars accepted in a sentence*/

printf(“The given sentence is   : %s”,sentence);

printf(“\nCase changed sentence is: “);
for(i=0; i < count; i++)
{
ch = islower(sentence[i]) ? toupper(sentence[i]) : tolower(sentence[i]);
putchar(ch);
}

} /*End of main()*/

/*——————————
Output
Enter a sentence
My Name is C
The given sentence is : My Name is C
Case changed sentence is: mY nAME IS c
————————————————*/

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. Sample – Program to enter a sentence and output the number of uppercase & lowercase consonants, uppercase & lowercase vowels in sentence..
  2. C program to read A (MxN), find the transpose of a given matrix and output both the input matrix and the transposed matrix.
  3. C program to find the sum of odd numbers and sum of even numbers from 1 to N. Output the computed sums on two different lines with suitable headings
  4. C program to read two matrices A (MxN) and B(MxN) and perform addition OR subtraction of A and B. Find the trace of the resultant matrix. Output the given matrix, their sum or Differences and the trace.
  5. C program to read two strings and concatenate them (without using library functions). Output the concatenated string along with the given string

Leave a Comment

Previous post:

Next post: