C/C++ :: Printing Number Of Vowel Case-insensitively?
Mar 18, 2012
Why my program doesn't work? Print number of vowels case-insensitively. For instance in the expression “come here”, there are 4 vowels.
#include <stdio.h>
#include <stdlib.h>
int vowels(char sentence[], char vowelletters[], int max) {
int vowelcounter=0;
int i,j=0;
[Code] ....
it just count one vowels not more.
View 2 Replies
ADVERTISEMENT
Sep 20, 2013
I want to have one case of my switch statement to print out how many times the user has chosen other cases in the switch statement. Such as "You have pressed 2 6 times and 4 3 times."
View 3 Replies
View Related
Apr 15, 2014
I'm taking a C++ computer science course right now, and one of the questions on my latest assignment is this:
"A partition of an integer n is a way of writing n as a sum of positive integers. For example, for n=7, a partition is 1+1+5. Write a program that finds all the partitions of an integer n using r integers. For example, all the partitions of n=7 using r=3 integers are 1+1+5, 1+2+4, 1+3+3, 2+2+3."
I've been struggling with this problem for a couple days now, and how to do it. I understand I need a recursive function to grab variables, and probably an array or vector to store them, but where to begin.
I've been reading documents on partition generating and the concept still eludes me, and any other questions on here or other programming sites using partitions don't seem to have a constraint on them.
View 2 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
Feb 18, 2015
I just dont know how to get my upper case and lower case equal...heres the program: Write a program to calculate utility cost for ACME UTILITY COMPANY. The company has 3 types of customers (R) residential, (C) Commercial and (G) government. Customers are billed based on the number of kilowatts used and they type of customer they are (R,C,or G).
Residential cusstomers are charged 0.25 cents per kilowatt hour for the first 500kw used, and 0.35 cent per kwh for all kw used over 500.Commercial customers are charged 0.22 cents per kilowatt hour for the first 999kw used, 0.29 cents per kwh for all kw used over 999 kw up to 1999 and 0.45 cents per kwh for all kilowatts used greater than 1999. Commercial customers that use over 2000 kw are charged a special surcharge of 100.0 in addition to the regular charges.
Government customers are charged 0.34 cents for the first 1500 kwh used(<=1500). 0.30 cent for the next 1000 kwh(1501-2500) and 0.25 cents for all kwh used over (>=2501)
in addition residential customer are charged .5% tax on the cost utilities while Commercial customers are 5% tax on the cost of utilities not including the special surcharge Government customers are not charged a tax
Code:
#include <stdio.h>
#include <math.h>
int main(void)
{
int R;
int ct;
int kwh;
int taxes;
int surcharge;
int charge
}
[code].....
the program should quit with Q and calculate the amount owed, utility charge, and surcharge
View 8 Replies
View Related
Mar 22, 2015
I've got this assignment where I have to print every other number from 1 to 10.
so far I've got this.
#include <iostream>
using namespace std;
int main() {
[Code].....
wondering if its really counting from 1 to 10 and only printing every other number.
View 9 Replies
View Related
Mar 6, 2015
have this program .. i tried to make it work to give me this result output:
Code:
input array {1,3,5,1,1,8,6,6,1,3,2,1,6,8,8}
[0]
[1] *****
[2]*
[Code].....
instead i'm having asterisks at the end of the output
View 14 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
Feb 8, 2013
I have been trying to write a recursive function to print the permutations of a n-digit number. This is the logic that i am trying to use.
1.call the permutation function,
2.keep the first digit in the first place and send the remaining 2 digits back to the permutation function recursively.
3.keep one of the two digits received and send the remaining digit to the permute function.
4. keep doing this till only one digit remains. this is the smallest solution so return it.
View 3 Replies
View Related
Jan 9, 2015
how to make a program in which a user is prompted to input four numbers like 1234 and then print those four numbers one by one on screen using only one variable..??
For example:
1
2
3
4
in ascending order...
I've done that with two methods but i am not sure whether the methods were correct..
View 1 Replies
View Related
Dec 17, 2013
I write this program to print the number of days for the month when the year and the month enters. This is not giving any result and i think that problem is with calling functions.
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
int leap_year(int year);
string days(string mounth);
string feb(string fab1);
void main(){
int year;
View 8 Replies
View Related
Mar 6, 2015
Program that has the user enter 5 digits then asks the user what they want to know about the 5 digits. My issue is when the program goes to print the value, its a totally ill related number
10 34 8 17 50
program prints out:
2 for smallest
79 for largest
119 for sum
23.80 for average
Code:
#include <stdio.h>#include <stdlib.h>
int main(void)
{
int smallNum, largNum, count=0, sum=0, value, choice;
double avgNum;
printf("Enter 5 integers
");
printf("
");
[Code]...
View 7 Replies
View Related
Mar 5, 2014
I'm trying to write a program that uses a loop to remove vowels from words. I'm really bad at this programming thing, I am getting an error code "[Error] expected unqualified-id before '{' token" when compiling, so there's no telling at this point if the code will even work. But, I need to get rid of that blasted error.
Here's my code:
1 #include <iostream>
2 #include <string>
3 #include <vector>
[Code]......
how to take an image to post in the forums. So I had to copy/paste/edit to fit :/.
View 3 Replies
View Related
Oct 20, 2014
So I've done this program that's supposed to count how many vowels or consonants you enter, depending on which one you choose, and also count the total number of characters you've entered. But it's not outputting the correct answers. The current output that it's showing seem to me that it's going out of bounds or something.
#include <iostream>
#include <cctype>
using namespace std;
[Code]....
View 3 Replies
View Related
Jan 25, 2013
WAP to remove vowel string using Pointer and Function...
View 6 Replies
View Related
Nov 12, 2013
adding a vowel counter to my recursive program which i completed.
#include < iostream>
#include <cstring>
using namespace std;
void reverseDigits(char num[], char revNum[], int,int);
int main() {
char letters[10] = {' '};
[Code]...
View 4 Replies
View Related
Nov 8, 2013
I'm trying to test if a character is a vowel. I made a separate function for the test, I'm not really sure how to get my return value to output whenever I call the function from main?
Also, I'm not good with while loops and can't figure out how to get it to continue asking whether or not the user wants to keep entering values.
#include <cstdlib>
#include <iostream>
using namespace std;
bool isVowel(bool);
int main(int argc, char *argv[]) {
char var1, cont;
[Code] ....
View 2 Replies
View Related
Jan 10, 2014
How to do this?
View 10 Replies
View Related
Jun 8, 2014
Repeat the vowel Problem 3 (0 / 0)Write a program that will repeat k times each single occurrence of a vowel in the input file "sp.txt" to a new file "output.txt". The first line of the input file contains only the parameter k. The first line (containing the parameter k) should not to be written in the output file.
I wrote the code but i cant figure out something. i read the file, i found the vowels but then i cant print them.
Code:
#include <stdio.h>#include <string.h>
#include <ctype.h>
#define MAX 100
int checkvowel(char c)
[Code].....
View 6 Replies
View Related
Nov 25, 2014
The program is supposed to read in a string from the user and then output the number of each vowel that the string has. My first function is initializing the vectors, and the one that I'm having trouble with is the function used to read the string from the user and save it.
Here's my code:
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;
// FUNCTION PROTOTYPES GO HERE:
void init_vectors(vector<char> & vowels, vector<int> & frequencies);
string read_text(const string & prompt);
[Code] ....
And I'm getting the error:
freq.cpp: In function ‘std::string read_text(const std::string&)’:
freq.cpp:74: error: no matching function for call to ‘getline(std::istream&, const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)’
I'm not too sure if I can't use the function getline here or if there is something wrong with the function prototype itself but I'm pretty sure there isn't an error there as it was given to me.
View 4 Replies
View Related
Mar 6, 2015
I have this case statement that is not performing as expected. For some reason ASE_OK and ASE_NotPresent both print out. Why is this? ASE_OK is a return value of 0 while ASE_NotPresent is -1.
Code: // Try to create the buffers and store it
switch (theAsioDriver->createBuffers(info, numChannels, bufferSize, callbacksInfo)) {
case ASE_OK:
std::cout << "ASE_OK";
input->bufferSize = output->bufferSize = bufferSize; // Buffer size is stored in both input and output
case ASE_NotPresent:
std::cout << "ASE_NotPresent";
errorMessage = "Could not find input or output devices.";
return NO_DEVICES_FOUND;
[code]....
View 3 Replies
View Related
Nov 6, 2013
I would like to choose same case for multiple switch conditions.
For example:
Code: switch(choice) //''if choice ==0 or choice ==1, chose same case''
{
case (0 || 1):
{
//execute steps
}
break;
default:
{
//execute steps
}
break;
}
The '||' inside case does not have the desired effect (although it compiles fine). How can I do it without using if-else statements.
View 1 Replies
View Related
Jan 5, 2015
I am building a tamagotchi like application/game. As for the leveling up and changing of character I am using a char value so that the icon can change as the character progresses.
Due to the fact that the value for level is changing I need it to also change for what is being used for the case statements
I know I cant use variables in case statements because I have tried every way I can think of.
The code is
switch(Area[y][x])
{
case '*':
Area[y][x] = Level;
break;
case 1:
{
CODE
}
}
Where I have the case 1 I need it to change as level increases (as level is starting at 1)
View 5 Replies
View Related
Jan 31, 2014
Ran into something today that does not make sense:
This compiles: Code: int x = 5;
switch(x) {
case 0:
{
int value = 5;
}
break;
[Code] ....
Ok so it doesn't like int value = 6 b/c of int value = 5 for case 0. However since the value in case 0 is declared within the brackets one would think it has case scope.
So I tried this:
Code: int x = 5;
switch(x) {
case 0:
{
int value = 5;
}
break;
[Code] ....
Now it doesn't like it b/c value has not been declared in case 1:. These two conditions cannot possibly be both true at the same time. You cannot disallow the declaration of value in case 1 b/c it interferes with value in case 0 and at the same time disallow me to use value from case 0 b/c it is not in scope. If it was not in scope then theoretically I should be able to declare value in case 1.
Both MSVS 2012 and 2013 exhibit the same behavior. I checked the standard and it is unclear on the matter.
View 7 Replies
View Related
Feb 11, 2013
Im going through a C tutorial and im going to create a Database as part of the course. Im just in the very beginning of the project so its a very simple program so far.
Code:
#include<stdio.h>
main(){
/*Variabler for att lagra information om skiva*/
char title[200];
char artist[100];
int tracks;
int price;
[Code] ....
The first switch case statement takes me to the menu of choice, 1 or 2. However, chosing menu option one and trying to input a title or artist name, the program crashes.
Next, going into menu option 2 and then trying to print out, for example, title nothing happend. The process just ends.
Again, im sure this simple prototype is full of errors ....
View 1 Replies
View Related
Oct 18, 2013
The program keeps on crashing when it finishes case 1
View 5 Replies
View Related