- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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; }
Advertisements