C++ :: Counting Total Number Of Each Topic Separately?
Feb 25, 2015
How can i count total number of each topic separately? For example total number of topic 1 between all nodes. To begin enter 10 and 7 to initial node number and number of topic.
#include <iostream>
#include <vector>
#include <list>
#include <stdlib.h>
#include<time.h>
#include<iomanip>
#include <iostream>
#include <string>
[Code] ....
View 1 Replies
ADVERTISEMENT
Feb 15, 2015
The project has to ask for ten grade inputs with a "for" loop and depending on the grade you input you either receive an "outstanding", "satisfactory", or an "unsatisfactory" output. At the end of the program I am supposed to display the total count of each category, total count of all categories and the average grade. The problem I have is that I cannot figure out a way to calculate what I have to display.
#include <iostream>
using namespace std;
int main() {
double grade = 0;
int g;
for (g = 0; g < 10; g ++) {
[Code] ....
View 2 Replies
View Related
Feb 7, 2015
decTotalAmountOwed = decAmountOwed + decAmountOwed;
This is what i've tried so far. The numbers are supposed to be added together once placed in listbox.
View 8 Replies
View Related
Feb 28, 2013
The program requires the user to enter 10 integers then print the total no. of even integer,highest even integer, lowest even integer then total no. of odd integer,highest odd integer, lowest odd integer
I already got the total no. of even integer and total no. of odd integer. But I don't know how will i get the highest even integer, lowest even integer and highest odd integer, lowest odd integer.
View 2 Replies
View Related
Mar 1, 2014
#include <windows.h>
int main() {
int i;
int y=6;
int x=9;
gotoxy(x,y);
//gotoxy(x,y) must be the coordinate that the number lies in.
[Code] ...
How to make this program that the output is a number that counts up to infinite (or we say just like a timer but there's no minute just all whole number counting up ) using for loop ? and when the number changes it also change in color !
and the color of a number is according to the color attribute of console output.
View 2 Replies
View Related
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
Jul 12, 2013
This function check a set of values from a text file and show it on the output.
void MatchNumber(int b){
vector<Rect> rects;
ifstream theFile("CheckNumber.txt");
[Code]......
I want to calculate how many times the number is repeated. So I have used freq[num] in that function. But I am getting the output like this-
The common number is = 5
The 5 repeated = 1 times
The common number is = 6
The 6 repeated = 1 times
The common number is = 4
The 4 repeated = 1 times
The common number is = 5
The 5 repeated = 1 times
The common number is = 5
The 5 repeated = 1 times
The common number is = 8
The 8 repeated = 1 times
The common number is = 9
The 9 repeated = 1 times
The common number is = 6
The 6 repeated = 1 times
The common number is = 6
The 6 repeated = 1 times
The common number is = 8
The 8 repeated = 1 times
So the value of freq[num] only shows 1 instead of calculating the number of repetition.
View 3 Replies
View Related
Mar 19, 2013
How can i count the total no of unique elements in an array? Like I have an array.
Code:
int array[]= { 2,1,4,0,3,3,0,0,1,2,1,1}
// As it has 0,1,2,3,4 as unique values so total no of unique values are=5
int unique =5;
View 4 Replies
View Related
Sep 30, 2014
I am trying to do a simple for loop that computes sum of a certain number of integers and then outputs the sum.
.text
.globlmain
main:
li $9, 0
li $10, 0
li $11, 10
li $12, 0
li $13, 0
[Code] ....
There error I keep getting is on the line with the branch
Instruction references undefined symbol at 0x0040003c [0x0040003c] 0x10200000 beq $1, $0, 0 [exit-0x00400038]
View 1 Replies
View Related
Jul 28, 2014
My project is to make a options menu for the user to select a shape and than draw out the shape. That whole process is already done and ready to go. What i am having trouble on is totaling the number of selected shapes. For example, at the end of the program i need to prompt a message saying ("You have selected "shape" this many times "number").
View 1 Replies
View Related
Feb 22, 2015
I have recently hit a stump with C++ and have been getting pretty frustrated with this assignment. I just can't seem to find out how to start the assignment. Basically for the first part of the assignment, I need to find the number of characters in this .txt file my teacher provided for me. The only exception is that I can only count the actual letters themselves, not spaces or punctuation. How would I go about doing this? I have read about functions like isalpha but can't figure out on how to fit them into code to do the first part of this assignment.
View 2 Replies
View Related
Feb 2, 2015
it looks like a popular method for determining the total lines in a file is to read the entire file character by character in search of ' '. I have a file with 5 lines, but for some reason this code isn't finding any instances of ' '. Is this possible? Is there a better way to get the number of lines in a file?
The file looks like this:
Code:
NAME: John
FRIEND 1: Steve
FRIEND 2: Andrea
FRIEND 3: Ken
OCCUPATION: Programmer
Code:
FILE *f = fopen(currentFile, "r");
if (f == NULL) perror ("Error opening file.
");
int ch, lines = 0;
while(!feof(f)){
[Code] .....
View 2 Replies
View Related
Apr 23, 2013
I'm a basic C++ programmer, and I am stuck on this problem. You work for a company that collects a set of numbers. The numbers are located in a data file named "./Data_File". The data file contains two columns. how do you count a certain number on the left column.
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
using namespace std;
#define DATA_FILE1 "./Data_File"
#define SUCEESS 0
#define FAIL 1
[code].....
View 1 Replies
View Related
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
Nov 3, 2014
I'm trying to write a program and I'm stuck. In order to continue on I simply need to know if there is a way of counting how many times the remainder of some number n when divided by some number x is 0.
For example
int lockers, i;
cin>>lockers;
//how can I count the amount of occurrences where lockers%i==0 while i<=lockers
A bit hard for me to articulate so let me know if it's unclear.
View 9 Replies
View Related
Jun 3, 2013
I was trying to make a function that would return how many lines are in a certain file. I was looking at [URL] which talks about how to count how many characters are in a text file. I just want the number of lines with in a file.
View 2 Replies
View Related
Mar 5, 2014
I am trying to write a function that will count the number of distinct values in an array of N size and return that number. For example array a[n] = {1, 2, 3, 1, 2, 3, 1}. My code won't look exactly like this because I am using an array that can be modified by user input. it is part of a bigger program that will also has a function for finding the Equilibrium Index for that same array. This is what my Code looks like:
void findDistinctValues() {
int t = 0;
int j = 0;
int disValue = 0;
for( i = 0; i < arraySize; i++) {
[Code] .....
This function works but the problem is it returns 16, or the number of times that the number being compared does not equal the one it is being compared to. how do I get it to only return the number of distinct values? The data set mentioned above is what I am using for input data so it should only have 3 values.
View 9 Replies
View Related
Sep 20, 2013
Code:
#include<stdio.h>
int main () {
int choice, opens, saves, news;
[Code]....
So what would I have to add in order for this code to display how many times the user has selected open, save or new?
View 2 Replies
View Related
Jul 21, 2014
I'm trying to copy a file into another file and copy the number of characters copied but my while loop doesn't even enter into a loop indicating the file is already at the EOF file character. I've confirmed this by placing the printf() statement inside the while loop, which doesn't print anything and by keeping it out of the while loop and changing the chars_copied to something like 9, it prints 9 for number of chars_copied. I don't understand why the file is already at the EOF character, I've tried this with a few more files, it's the same result.
Code:
#include <stdio.h>
int main(void){
FILE *input_file, *output_file;
int c, chars_copied=0;
if((input_file=fopen("C:workmarks.txt", "r"))==NULL)
perror("input file open failed");
[Code] ....
View 13 Replies
View Related
Mar 27, 2013
Summary: 6 companies have a product in 5 different warehouses. Each company is identified by a positive ID number and each warehouse is identified by a number (1 for the first, 2 for the second,…)
Object: the object of this assignment is to write a C++ program which asks the user to enter a company ID number, and the number of products in each of the warehouses. It then computes and prints the total number of products for that company
If the total number of product is less than 100, it prints the message “place a new order”
Input: for each company, its ID, and the number of products in each warehouse with appropriate prompt messages.
Example: Enter company ID number: 101
Enter number of products in warehouse #1:30
Enter number of products in warehouse #2:60
Enter number of products in warehouse #3:0
Enter number of products in warehouse #4:5
Enter number of products in warehouse #5:27
The total for company 101 is:122
Output: for each company, the total number of product, and the message “place a new order” if the total number of product is less than 100.
Method:
1. Define global variable, int total_prod to hold the total number of products for a company
2. define the function void compute_total() that uses a loop to read the number of the products in all warehouses for one company, computer the total number of products and store it into the global variable total_prod.
3. Define the function void new_order() that determines if a new order need to be placed as follows: if the total number of products (in the global variable total_prod) is less than 100, it prints the message “place a new order”
4. Your function main does the following in a loop:
- read a company ID number
- call function compute_total() to read the number of the product in all warehouses for that company, and to compute their sum
- print the total number of the product for that company with an appropriate message
- call the function new_order() to determine if a new order need to be placed.
View 17 Replies
View Related
Mar 5, 2013
Write a C++ program to calculate the fewest number of each denomination needed to pay a bill of amount TOTAL. For example, if the end user enters $97 for TOTAL, program will output that the bills would consist of one $50 bill, two $20 bills, one $5 bill, and two $1 bills. (Assume that the amount is in whole dollars, no cents, and only $100, $50, $20, $10, $5, and $1 denominations are available.) Aid: You may want to use the modulus operator %.
View 1 Replies
View Related
Nov 4, 2013
I am currently working on an assignment.
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
char letter;
int count = 0;
double ppl = 0;
double finalCost = ppl * (count - 1);
[Code] ....
I am trying to create a word counter program that asks for the price per letter and then asks for the sentence they are writing. The app should then calculate the number of letters and give the total cost similar to:
You have 40 letters at $3.45 per letter, and your total is $138.00.
Everything compiles fine but when I run it the inputs don't work and it outputs:
You have -1 per letter, and your total cost is $-0.
View 2 Replies
View Related
Jul 27, 2014
I've been struggling with this for a while, I have to write a function that accepts a word (in my case the word is "the") and file pointer, and counts the number of times the given word appears (case insensitive) within the file associated with the pointer. This means the two words "the" and "THE" should both be counted.
Here is my code:
int WordCount :: countWords(string wrd) {
int counter=0;
string temp = "";
while (getline(*file,temp)) {
for (int i = 0; i < temp.length();i++) {
[Code] ....
This is what I have come up with, but I get an incorrect value. It was suggested to us to consider using the strcpy() or strstr() functions, but I don't know how to use them.
View 6 Replies
View Related
Apr 11, 2015
Ok, so I am writing this program with 10 different functions, and one of those functions needs to count how many times 0 appears in a text file. I've done this before, but I am so stumped right now. Should I get the numbers from the 2d array I have, or should I just use the text file here? Here is what I have right now:
int toursMissed(int scores[][COLS]){
int counter;
for(counter=0;counter<=96;counter++){
if(scores==0){
counter++;
return counter;
}
}
View 7 Replies
View Related
Jul 27, 2014
I have to write a function that accepts a word (in my case the word is "the") and file pointer, and counts the number of times the given word appears (case insensitive) within the file associated with the pointer. This means the two words "the" and "THE" should both be counted.
Here is my code:
int WordCount :: countWords(string wrd)
{
string temp;
int counter;
while (!file->eof())
{
*file >> temp;
if (temp == wrd)
[Code]...
Unfortunately this does not work,
View 1 Replies
View Related
Feb 12, 2014
So I'm trying to count the number of lines in a text file that is inputted by the user. Also the code doesn't sum up the last number of the text file (exmp it calculates and print only 14 from 15 numbers). I'm a beginner in c++ programing.
View 3 Replies
View Related