Computer Science, asked by mahjabeenbano5120, 1 year ago

Write a c program to count number of uppercase and lowercase letters in a given string. the string may be a word or a sentence.

Answers

Answered by prashilpa
9

Answer:

Explanation:

#include <stdio.h>

int main()

{

  char str[100];

  int l =0, u = 0;

   int i = 0;

   scanf("%s", str);

   while (str[i] != 0)

    {

          if ((str[i] >= 'a') && (str[i] <= 'z'))

                  l++;

          if ((str[i] >= 'A') && (str[i] <= 'Z'))

                  u++;

     }

    printf("Lower case letters are %d and upper case letters are %d\n", l, u);

return 0;

}

Answered by sushiladevi4418
5

Answer:

C  program to a count number of uppercase and lowercase letters in a given string.

Explanation:

 #include<stdio.h>

 

int main() {

  int upper = 0, lower = 0;

  char ch[80];

  int i;

 

  printf("\nEnter The String : ");

  gets(ch);

 

  i = 0;

  while (ch[i] != '') {

     if (ch[i] >= 'A' && ch[i] <= 'Z')

        upper++;

     if (ch[i] >= 'a' && ch[i] <= 'z')

        lower++;

     i++;

  }

 

  printf("\nUppercase Letters : %d", upper);

  printf("\nLowercase Letters : %d", lower);

 

  return (0);

}

Similar questions