Visual C++ :: Program To Reverse Sentence - Case Sensitive
May 31, 2014
I have to write a program to reverse a sentence like
cat
tac
but my program is case sensitive. Like if i enter sentence it gives me ecntenes(which is wrong). How to make it non case-sensitive using vectors? (I cannot use #algorithims)
// BackWardsSentence.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
string BackWords (string sentence);
int BackSentence (string sentence);
Im writing a c program that reverses the words in a sentence,
Example: you can cage a swallow can't you? you can't swallow a cage can you?
I have it all working, except the fact that I dont know how to get the words themselves to turn around. Heres my code and an example of the output im getting.
Output Im getting:
Enter a sentence: you can cage a swallow can't you? Reverse of sentence: uoy t'nac wollaws a egac nac uoy?
Code: #include <stdio.h> #include <stdlib.h> #include <ctype.h> #define MAX 200 /*Decent number of chars for a sentence*/ int main()
I am trying to write a program that ask the user to enter a sentence and then a word to be searched for in the sentence. The program must then search for the word in the sentence in a loop and continue to output each place the word is found. For example if the sentence is : I like pickles, pickles, pickles
and you searched for pickles it would return pickles found at 7, pickles found at 16, pickles found at 25.
I am having trouble writing the equation to make the find keep searching after each occurrence of the word being searched. Here is the code I have so far
HTML Code: #include <iostream> #include <string> using namespace std; int main() { string paragraph;
I want to read sentence from command line. I open some program which run in command line and I have to wait for that program process. So , I don't know when process success .I can't type next command if can't read sentence from command. I use
Code: wprintf(GetCommandLine());
but it show
"C:UsersPKRUdocumentsvisual studio 2010ProjectsVirus ScanDebugMyProgram
so I'm creating a program that generates random sentences with structs..I'm trying to use structs and and create 4 different groupings article, noun, verb, and preposition. Then I'm trying to use "r = rand() % ;" to randomly pick one one word from each group to make a sentence. this is what i have
Code:
typedef enum article { the = 1, a, one, some, any } article; typedef enum noun { boy = 1, girl, dog, town, car }
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
I tried to write a menu program as a switch-case structure with a separate function for a switch-case structure itself. The outcome for it currently is an undesired one
Code:
#include <iostream> using namespace std; int menu(int answer); int main()
[Code].....
The output I get is one where it's just an infinite loop of "Bad choice! Please try again later.".
So I have started this program for class but am stuck on what to do next. Basically you need to create a function to compare 2 strings (case-insensitive). The strings shouldn't be altered and the return value should be similar to strcmp.
This is my main file
#include <iostream> //#include <cstring> #include <iomanip> #include "rpstrings.h" using namespace std; int main () { char Str1[20], Str2[20]; short result;
[Code] .....
I don't know if I labeled the files correct. what I need to do is to add 2 defaulted arguments which will allow the user to request that you skip spaces and/or skip punctuation when doing the comparison.
Also, how I can sort the numbers when they aren't justified with leading 0's and if they aren't in the lead string (kinda of like the natural sort).
Trying to write a program that calculates a students grade based on how many assignments have been graded. I am using a switch case since there is a total of 5 assignments, however when I enter case 1, and enter in how many I got out of 100, it just closes the program it doesn't go to the next part.
#include <iostream> using namespace std; char calculategrade(int total); int main() { // local variable declaration: char input;
I've written a simple program, which asks the user to respond to a YES or NO question using the character Y/y for YES and the character N/n for NO. The foundation of this program is based around several IF statements implemented to aid in finding the ASCII value of the character entered before invoking the corresponding cout statement that informs the user which character they entered. My Question: How should a program be written to deal with ignoring case sensitivity in regards to the users' input?
Here is my amateurish attempt,
Code: #include <iostream> using namespace std; int main()
[Code] .....
The following are IF statements written for the program to determine whether the user answered YES or NO. The program then performs the cout statement that contains the corresponding character to the ASCII value found.
I have my Reverse Polish calculator compiling and everything but for the assignment I need to handle a few exceptions that I can't seem to get. First off I'm trying to make the program exit if the user enters only "0" but since the input i'm using is string, I cant figure out how to code
"If the first node is 0 and the next node = NULL, return true"
Here is my code: #include<iomanip> #include<iostream> #include<stdlib.h> #include<stdio.h> #include<string> #include<sstream> using namespace std;
I made a simple little program that takes text from the clipboard, and spits out all the lines I've copied one at a time (so my program can analyze it).
everything works perfectly, except, it spits it own in the wrong order, I want it to spit out from bottom to top. but currently it spits out the data from top to bottom. here is my code :
Code: #include <iostream> #include <Windows.h> #include <string> #include <sstream> using namespace std; int main() { HANDLE clip; // assigns the var. clip to hold a handle ID.
[Code] .....
I want this loop to run backwards! Like it say's what I want to work backwards. Where as I know how to flip a while loop like this: while(x < 5), how to flip a loop like the one I'm using. how I can do this?
l need to write a program which writes out its command line arguments in reverse order one per line. The output from the program should look like this:
% a.out Two roads diverged in a yellow wood wood yellow a in diverged roads Two