I cant get my summary_Count function to work i figured it out that it stops working on the for loop part here - void summary_Count(char random[], int n)
-
{
-
-
int t=0;
-
int count[26]={0};
-
-
for(int a=0; a<=25; a++)
-
{
-
for(char i=97; char i=122; i++)
-
{
-
for(int j=0; j<=n; j++)
-
{
-
if (random[j]=i) count[a]++;
-
}}}
-
-
-
cout<<"\nSummary for the characters:"<<endl<<endl;
-
for(char ch='a';ch<='z';ch++)
-
{
-
cout<<ch<<" = "<<count[t] <<endl;
-
t++;
-
}
-
-
}
-
The overall goal is to generate random charcters then count them and print how many a,b,c...ect. I made that for loop to count my letters but when i run it it stops right when it reaches the for loops. My full code is here its kind of mess though. -
-
#include <iostream>
-
#include <cmath>
-
#include <cstdlib>
-
#include <stdio.h>
-
#include <ctype.h>
-
-
using namespace std;
-
void parameters(int& seed,int& n);
-
char getChar(int seed);
-
void printCharcter(char random[],int n);
-
void summary_Count(char random[], int n);
-
int main()
-
{
-
bool repeat=true;
-
int seed;
-
int n;
-
char random[n];
-
char again;
-
srand(seed);
-
do{
-
parameters(seed, n);
-
-
for(int i=0; i<n; i++)
-
{
-
random[i]=getChar(seed);
-
}
-
printCharcter(random,n);
-
-
for(int j = 0; random[j] != '\0'; j++)
-
{
-
random[j] = tolower(random[j]);
-
}
-
-
summary_Count(random, n);
-
-
-
cout<<"\nDo you wish to try again? (Y/N) ";
-
cin >> again;
-
cout<<endl;
-
if (again == 'n' || again == 'N') repeat=false ;
-
else repeat=true ;
-
}
-
while(repeat==true);
-
-
-
system("PAUSE");
-
return 0;
-
}
-
-
void parameters(int& seed,int& n)
-
{
-
-
cout<<"Enter a seed number:";
-
cin>>seed;
-
cout<<"\nHow many charcters do you want generated:";
-
cin>>n;
-
if(n>100)
-
{
-
cout<<"Invlaid input, enter again"<<endl;
-
cin>>n;
-
}
-
-
cout<<endl;
-
-
}
-
char getChar(int seed)
-
{
-
-
char random = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"[rand() % 52];
-
return random;
-
}
-
void printCharcter(char random[],int n)
-
{
-
cout<<"Charcters generated are:"<<endl;
-
for(int i=0; i<n; i++)
-
{
-
if (i% 10== 0) cout<<endl;
-
cout<<random[i];
-
-
}
-
}
-
void summary_Count(char random[], int n)
-
{
-
-
int t=0;
-
int count[26]={0};
-
-
for(int a=0; a<=25; a++)
-
{
-
for(char i=97; char i=122; i++)
-
{
-
for(int j=0; j<=n; j++)
-
{
-
if (random[j]=i) count[a]++;
-
}}}
-
-
-
cout<<"\nSummary for the characters:"<<endl<<endl;
-
for(char ch='a';ch<='z';ch++)
-
{
-
cout<<ch<<" = "<<count[t] <<endl;
-
t++;
-
}
-
-
}
-
4 2362
for the if statement i forgot the second = but that still didn't fix my problem
I am little confused.. does it compile at all???
anyway your for loop seems endless fix your forloop in the first code block. On line 9 the condition is always true
oh cant believe i didnt see that yea it compiles but it dosent work,
You really only need one loop. Just loop through the random array and increment the count index based on the ascii value.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: whisper |
last post by:
Medium/small site with mod_python and sqllite or mySQL running Python
2.3.3 or later on Apache 2.x.
I can do the python and CGI, but might need a _little_ hand holding for
the rest.
Will also...
|
by: ratedr1 |
last post by:
I am currently trying to label rings (jewelry). They make specialized
tags (shaped like a butterfly, barbell, dumbell, etc) for this purpose,
the label goes through the ring, and then the ends...
|
by: Chad A. Beckner |
last post by:
Hey all,
I have a ASP .NET webpage which contains several panels. When I click a
button on the first "panel" page, it postsback to the same page, and I
switch the visibility of the panels...
|
by: Keith Kowalski |
last post by:
I anm opening up a text file reading the lines of the file that refer to a
tif image in that file, If the tif image does not exist I need it to send an
email stating that the file doesn't exist...
|
by: Massimo Bonanni |
last post by:
Hi, I try to implement ASAP protocol in my web service, but I find a very
hard problem.
I define my SOAP Header:
public class Request : SoapHeader
{
|
by: briggsie2006 |
last post by:
I need to write a program called wc.py. It promts the user to input a filename and outputs the number of lines, words, and, characters in the file. I really need help on this because I don't know...
|
by: Karthik D V |
last post by:
Hello All,
I have a table like this
ID CHARACTER
----------- ---------
1 A
2 A
3 B
4 B
|
by: fortwaynemarketplace |
last post by:
Need these two scripts;
1. (Action) script for email (outlook express or...) to come up in .swf enviroment. I have created a button (email us), need action scritps to send/recevie an email.
....
|
by: Alenik1989 |
last post by:
I wrote this code, but I'm not able to test it because im getting 3 errors. So I'm not sure that this code will work properly or not!!!
the code in
#include <stdio.h>
#include <stdlib.h>
int...
|
by: Coxmg |
last post by:
Here is the code, ACCESS 2007:
Hello, I have a dialog box that opens on a form that lets the user browse files. I simply want to limit it to Folders, how can I do that? Need ASAP. Thanks. ACCESS...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |