1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
//
// main.cpp
// Threshold.cpp
//
// Created by Mikel Wille on 11/30/17.
// Copyright © 2017 The Error 404. All rights reserved.
//
#include<stdio.h>
#include<iostream>
#include<iterator>
using namespace std;
int main()
{
int others = 0, numbers = 0, space = 0, punct = 0, character = 0, letters = 0,upper = 0, lower = 0, digit=0, special=0;
char ch[80];
int i;
printf("\nEnter The String : ");
gets(ch);
for (i = 0; ch[i]!='\0';i++)
int main = 0;
string line; // variable used to read a line from file
ifstream myfile("/Users/TheKid/Documents/Threshold.cpp/Threshold.cpp/text.data");
if (myfile.is_open()) // checking if the file was opened
{
if (ch[i] != ' ')
character++;
if (ch[i] >= 'a' && ch[i] <= 'z' && ch[i] >= 'A' && ch[i] >= 'Z' && ch[i] != ' ') // Checking for spaces
letters++;
if (ch[i] >= 'A' && ch[i] <= 'Z')
upper++;
else if (ch[i] >= 'a' && ch[i] <= 'z')
lower++;
else if(ch[i] >='0' && ch[i] <='9')
digit++;
else if (ch[i] != ',' && ch[i] !=';' && ch[i] != '!' && ch[i] != ' ' && ch[i] != '.' && ch[i] != ':' && ch[i] != '?' && ch[i] != '"' && ch[i] != '-' && ch[i] != '+' && ch[i] != '/')
special++;
else if(ch[i]!=' ')
punct++;
else if (ch[i] == ' ')
space++;
else if (digit >='0' && ch[i] !='9')
numbers++;
else if (ch[i] != '@'&& ch[i] != '#' && ch[i] != '$' && ch[i] != '%' && ch[i] != '^' && ch[i] != '*' && ch[i] != '(' && ch[i] != ')' && ch[i] != '_' && ch[i] != '+' && ch[i] != '{' && ch[i] !='}' && ch[i] != '<' && ch[i] != '>' && ch[i] !='~' && ch[i] != '`')
others++;
}
printf ("\nNnumber of characters: %d", character);
printf ("\nNnumber of letters: %d", upper + lower);
printf ("\nNumber of Uppercase Letters: %d", upper);
printf ("\nNumber of Lowercase Letters: %d", lower);
printf ("\nNumber of Digits: %d", digit);
printf ("\nThe number of special characters: %d", special);
printf ("\nPunctuation Characters: %d", punct);
printf ("\nNumber of spaces: %d", space);
printf ("\nNumber of words: %d", space +1);
printf ("\nNumber of numbers: %d" , digit / 2 );
printf ("\nNumber of others: %d", others);
}
|