
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
Count spaces, uppercase and lowercase in a sentence using C
#include int main() { char str[100],i; int upper = 0, lower = 0, number = 0, special = 0,whitesp=0; printf("enter string"); gets(str); for (i = 0; i < str[i]!='\0'; i++) { if (str[i] >= 'A' && str[i] <= 'Z') upper++; else if (str[i] >= 'a' && str[i] <= 'z') lower++; else if (str[i]>= '0' && str[i]<= '9') number++; else if(str[i]==' ') whitesp++; else special++; } printf("Upper case letters: %d
",upper); printf("lower case letters: %d
",lower); printf("Numbers: %d
",number); printf("whitespace: %d
",whitesp); printf("sp chararcter: %d
",special); return 0; }
- Related Articles
- Count Uppercase, Lowercase, special character and numeric values in C++
- C program to remove spaces in a sentence using string concepts.
- Replacing upperCase and LowerCase in a string - JavaScript
- Conversion of whole String to uppercase or lowercase using STL in C++
- C Program for LowerCase to UpperCase and vice-versa
- C# Program to convert first character uppercase in a sentence
- C Program to convert first character uppercase in a sentence
- Maximum distinct lowercase alphabets between two uppercase in C++
- Write a C program to convert uppercase to lowercase letters without using string convert function
- Java program to convert a string to lowercase and uppercase.
- Count palindrome words in a sentence in C++
- How to test if a letter in a string is uppercase or lowercase using javascript?
- Convert spaces to dash and lowercase with PHP
- Golang Program to convert Uppercase to Lowercase characters, using binary operator.
- Convert string to lowercase or uppercase in Arduino

Advertisements