C++ :: Make Program That Counts Number Of Words / Lines And Vowels?

Mar 13, 2014

So I need to make a program that counts the number of words, lines, and vowels in a program. Punctuation and white spaces are not counted in any of the counts. I have this so far and the words, and lines work and are correct but I can't seem to get the vowel count to work.

#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <string>

[Code]....

View 1 Replies


ADVERTISEMENT

C++ :: Counts Number Of Words In A String That End With Ng

Dec 10, 2013

I am trying to write a code that counts the number of words in a string that end with ng.

I started with this but this just checks the end of the string. I need it to check everyword in the string and also count them up.

int main() {
string s;
cout << " enter string ";
getline(cin, s);
string end;
end = s.substr(s.length()-2, 2);
cout << end;
cout << endl;
return 0;
}

View 19 Replies View Related

C++ :: Count Number Of Words And Lines Then Print All Words

Dec 20, 2013

I have written below program to count number of words and lines and print the all the words.

#include <iostream>
using namespace std;
#include<fstream>
#include<string.h>
int main() {
ofstream outfile;

[Code] .....

Its compiling fine but when executed its displaying I infinite times...

View 3 Replies View Related

C :: Program That Counts Letters Of 3 Lines Of Input From User

May 26, 2013

So I am writing a program that counts the letters of 3 lines of input from the user. I am using a 3 x 80 character array as the "notepad". Upper and lower case characters are incremented on the same counter array.

Code:

/*Letters in a string*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
void countAlphabet(char *);
/*Character counting array*/
int alphabet[26] = {0};

[Code]...

View 3 Replies View Related

C++ :: Program That Opens A File And Counts White Space Separated Words

May 17, 2013

Question is : Write a program that opens a file and counts the whitespace-separated words in that file.?

my answer is :

#include <iostream>
using namespace std;
#include <iostream>
#include <string>
#include <fstream>

int main() {
string filename = "Question 1.cpp"; // File name goes in here

[Code] ....

Now I am not sure if im suppose to get a msg saying : The file "Question 1.cpp" has 0 words.

im wondering is the question that im being asked, asking me to input a string of words and then the compiler when it builds and runs the program counts the word spaces.?

View 5 Replies View Related

C++ :: Print Out Number Of Words And Lines In A File

Jan 29, 2012

Write a program that prompts the user for the name of a file. Then it opens the file, and counts the number of words and lines in the file, and prints out those counts.

I think I possibly could somehow use a counter to increment using getLIne() until getLine() returns NULL, but the problem is, I'm worried if I try that, a file that looks like this:

Bla bla bla bla bla lkfdljkfaklafdskjladsjkdfkjlkdfjdfshafdsjkjrerjkkjfaddjkfsafkjdjakdfsjkasfjkjkfdskjldfjkfjkdjfkdsakdjfkjfdkjdfskjfdsk
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjdfkerea
blkjadkjlfdskjldfkjlfdkjfdjkdfsjkldfskljfksfdljfd

Only register four lines and not get the one after the fourth line.

So I was thinking of something like

Code:
#include <iostream>
#include<ifstream>
#include<cstring>
#include<string>
#include<vector>
#include <cstdlib>
using namespace std;
iostream keyboard;
ifstream file;
iostream cin;

[Code] .....

Did I do that right? Will that count the number of words and number of lines correctly?

View 14 Replies View Related

C :: Counts Keystrokes / Alphabetical Characters And Vowels - Press Enter To Exit A Loop?

Oct 28, 2014

So I have been assigned a program that counts keystrokes, alphabetical characters, and vowels. I have the program working as desired but I just can't figure out how to make it end upon ONLY the "return" key being pressed.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main ( void ) {

[Code] .....

View 7 Replies View Related

C++ :: Program That Counts Number Of Occurrence Of A Letter In A File

Feb 3, 2013

I need to create a program that asks the user for the filename, then counts the number of occurrence of each letter in that file.

Ex. if the file contains
Absacsac
asdasda

Output will be

a = 6
b = 1
c = 2
.
.
.
z = 0

This has been my program so far:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#include <cstdlib>
void countingFunction(string sentence) {

[Code] .....

View 2 Replies View Related

C++ :: Open A File And Counts White Space Separated Words

May 3, 2013

Write a program that opens a file and counts the whitespace-separated words in that file.?

My code that i wrote for this example is as follows...

#include <iostream>
using namespace std;
#include <iostream>
#include <string>
#include <fstream>
int main() {
string filename = "Question 1.cpp"; // File name goes in here

[Code] ....

Is this correct or am i missing something?

View 6 Replies View Related

C++ :: Make Program Read More Lines On TXT Document?

Oct 6, 2014

how could this program tell the ID's and Passwords of more than one line in the text document?

# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# include <string.h>

[Code].....

View 2 Replies View Related

C++ :: How To Make A Program That Converts Input Numbers Into Equivalent Words

Nov 16, 2013

I've reached a point in "Jumping into C++" where I need to make a program that converts input numbers into their word equivalent.

So far I've made it work for numbers 0-9999. I've tried implementing 10000-99999 but there are problems with the order of the words printed (57865 would print fifty thousand seven thousand eight hundred sixty five). But besides that, the program is absolutely enormous (for me) and I'm wondering if it can be shortened. Keep in mind I can only use loops and if statements so far. Here it is:

Code:

#include <iostream>
#include <string>
void extras(int e);
void digits(int x);
void tens(int xx);
void hundreds(int xxx);
void thousands(int xxxx);
//void tens_of_thousands(long xxxxx);

[Code]....

View 6 Replies View Related

C :: Program Count Number Of Lines Of Read Text File

Jan 25, 2013

I have a .txt file that contains, together with a few characters, columns of values that I want to save in different files like is written in the program (file 1, file2, file3 - a with x, b with y, c with z). The pattern of the source text file is like this:

known_vector frame1 151 65 0 frame2 151.000763 64.538582 0.563737
known_vector frame1 152 65 0 frame2 152.000702 64.542488 0.560822
known_vector frame1 153 65 0 frame2 153.000671 64.546150 0.558089

Until now I could manage to split the files, but the output gives me only zeros. First the program count the number of lines of the read text file, then it should display the desired columns of double values in three other .txt files.I've got for the three .txt files columns like this:

0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

View 2 Replies View Related

C :: Program To Count Number Of Lines In Text File And Reverse Contents

Jan 25, 2015

C program to count the number of lines in a text file and reverse the contents in the file to write in an output file.

ex :
input
one
two
three

output:
three
two
one

View 6 Replies View Related

C :: Euler Project - Number Letter Counts

Apr 30, 2013

I am working on Euler Project exercise number 17. Here is the problem from the website.

"If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?"

Code:
#include <stdio.h>
#include <string.h>
#define LENGTHOFHUNDRED 7
#define LENGTHOFONETHOUSAND 11
#define NUMSTART 1
#define NUMEND 1000

[Code] .....

View 8 Replies View Related

C++ :: Counting Characters / Words / Lines And Digits

Mar 20, 2013

I am writing a program for my class in C++. For this program we are required to use different fuctions and prototypes outside of main. We have to determine the number of characters, lines, sentences, digits, words, etc. in a particular function the user types in.

View 1 Replies View Related

C :: Working With File And Counting Characters / Words And Lines

Dec 17, 2013

I have to write a program (on linux) which will count character, words and lines like wc linux command. I'm trying to write this for last 3 days... First part of app I did and it works fine - command line options to choose. Then I've got a function read_file which I have to use to read a file. One of the options is to get the file name from user and if user will not type any name then the standard file is ubuntu dict file /usr/share/dict/words, this is not working as well...

Counting characters and lines is working fine but because I don't know how to get text from read_file wrote code to read file interior this functions. Words counting is working partly - everything is fine until there are two or more spaces, tabs one after another then counts extra words. Finally I need child processes in words and lines counting functions. Parent process should waits for all childs to finish and should be pipes to submit character counts back to parent process. How to do all this things with processes...

Code:

#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
/*size of character buffer to read in a file. */
#define BUFFSIZE 1000000

[code]....

View 2 Replies View Related

C Sharp :: Call That Counts Number Of Entries In Database - Cast Error

Jul 14, 2013

I have an issue with a database call. I've got a database call that counts the number of entries in the database:

        private static Int32 dbCount() {
            SqlCommand cmd = new SqlCommand("SELECT COUNT (*) FROM Employees", conn);
            conn.Open();
            Int32 count = (Int32)cmd.ExecuteScalar();
            conn.Close();
            return count;
        }  

Afterwards I'm using this as a check throughout my application:

           if (dbCount > 0)  {
                // do something
            }  

When I execute this code I'm getting the following error: "Operator '>' cannot be applied to operands of type 'method group' and 'int'"

So I'm guessing it has something to do with the cast of the dbCount-object but I don't understand why as I already stated that the count-object to be an Int32.

View 3 Replies View Related

C++ :: Counting The Number Of Vowels

Feb 10, 2015

I am unsure how to write a function which modifies the content of the 1D character array and counts the number of the vowels. the following is the array that i have.

char text[MAX+1] = {'T', 'e', 's', 't', 'e', 'r', EOT};

the output that i am trying to produce is should look something like this

the number of vowels is 2, e, e.

I am unsure how to do this.

View 3 Replies View Related

C++ :: Counting Number Of Vowels In A Sentence?

Nov 29, 2014

I want to count all the vowels in a string (a, e, i , o, u) and display it as a text-based histogram for example:

[INPUT] The black cat sat up on the orange mat!

[OUTPUT]
A: *****
E: ***
I:
O: **
U: *

The asterisks are supposed to correspond to the number of vowels that are counted (using increments and the function setfill()).

#include <iostream>
#include <string>
#include <iomanip>

[Code]....

This is my output during compilation:

[OUTPUT]
The black cat sat up on the orange mat! 0 0 0 0 0
A:
E:
I:
O:
U:

View 1 Replies View Related

C++ :: Make The Program Generate A Different Number?

Apr 23, 2013

i wanna no if i can make the program generate a different number everytime you guess the number right and want to play again. it always generates the same number

#include <iostream>
#include <ctime>
#include <cstdlib>

[Code].....

View 9 Replies View Related

C++ :: Read Story From Input File / Separate Words And Output Lines On Which The Word Occurs

Feb 21, 2014

I have program that is supposed to read in a story from an input file and separate the words and output the lines on which the word occurs. It needs to read in another input file that has a list of words (1 per line) to ignore. i.e. skip them when running through the story. This is what I have so far, I've changed multiple things trying to get it running....

#include<iostream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<string>
#include"split.h"

[Code] .....

View 1 Replies View Related

C :: Make Program That Asks User For Number?

Oct 15, 2013

So I'm trying to make a program that asks the user for a number and then prints a statement the same number of times the user entered. 3 different statements, using the 3 loops (for, while, and do while). I made the program but for some reason the statement from the do while loop goes off infinitely.

MY CODE:

The error:

View 8 Replies View Related

C/C++ :: Make A Program Which Can Work As A Backspace Number?

Dec 9, 2013

how work backspace key in c++.i want to make a program which can work as a backspace number

View 1 Replies View Related

C :: Make Program That Takes Number Input From Tuser?

Jul 27, 2013

I have to make a program that takes a number input from the user and prints the corresponding fibonacci sequence number. For example, for the input of 3, it should print 2 since the third term in the fibonacci sequence is 2.

I am not sure how to do this so for my attempt, I used the formula found in this website. A Formula for the nth Fibonacci number

Here is the program so far. It doesn't produce the correct output.

Code:

#include <stdio.h>
#include "genlib.h"
#include "simpio.h"
#include "math.h"

[Code]....

View 11 Replies View Related

C++ :: Program To Make A Table For Any Input Number - Do While Loop

Nov 27, 2014

Write a program to make a table for any input number and then continuesly ask to press y to print more table and if you press any key other than y then program must be terminate using while loop and do while loop. How to start or end with it.

View 2 Replies View Related

C++ :: Creating User Defined Function To Count Number Of Vowels

Oct 7, 2013

The output I'm getting here just counts every letter in the sentence and counts them as vowels. I'm trying to make the user defined function return the amount of vowels within the sentence.

#include <iostream>
#include <iomanip>
#include <cmath>

[Code].....

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved