Visual C++ :: Reverse Sentence - How To Make Program Non Case-sensitive Using Vectors
May 25, 2014
I had been tasked to create a program that reverses a word i.e.
cat
tac
How to make my program non case-sensitive using vectors?
Code:
// 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);
string BackWords1 (string sentence);
[Code] .....
View 2 Replies
ADVERTISEMENT
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);
[Code] .....
View 2 Replies
View Related
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?
// 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);
[Code] ......
View 3 Replies
View Related
Feb 5, 2013
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()
[Code] ....
View 2 Replies
View Related
Sep 26, 2014
The following Program ask a user to input a sentence. Program alphabetically sort individual character for each word.
My problem is, how do I ignore case sensitive if a user enters a uppercase letter. I try using stricmp but ran into some errors.
Below code:
#include <iostream>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;
void bubblesort(char a[]);
int main() {
char sent[50];
[Code] ....
Current output:
input: today is a great day
output: adoty is a aegrt ady
Using Uppercase:
input: Today is a Great Day
output: Tadoy is a Gaert Day
What I want:
input: Today is a Great Day
output: adoTy is a aeGrt aDy
View 6 Replies
View Related
Apr 2, 2012
I am trying to write a program that takes a sentence and reverses the word order.
For instance This is a Bird would become Bird a is This
Code :
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main (void) {
char input_buffer[1024];
char middle[1024];
[Code] ....
View 3 Replies
View Related
May 23, 2014
How to search form insensitive to case sensitive? I'm trying to emulate the behavior of the function "grep" in Unix.
#include <iostream>
#include <fstream>
#include<string>
#include<vector>
#include <ctype.h>
using namespace std;
int main(int argc, char** argv) {
[Code] .....
View 3 Replies
View Related
May 21, 2014
I am trying to write a program in which i enter sentences and then gives the reversed output
E.g.: -
INPUT
Enter the number of sentences
3
This is a sentence
Program
You are great
OUTPUT
sentence a is This
Program
great are You
I wrote the following code but its failing when im trying to enter a sentence
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
void str(char*, int);
void main() {
char *word[25];
[Code] ....
View 7 Replies
View Related
Jun 3, 2013
I need to do program where i will input sentence and then output it in reverse order. Example: today is Monday ----> Monday is today. So I have this:
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char niz[20],niz2[20];
int lenght,k=0;
[Code] ....
For output I only get one word of sentence,example: Monday is today--->today and nothing else.
View 5 Replies
View Related
Oct 9, 2013
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;
[Code] ....
View 5 Replies
View Related
Oct 11, 2013
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;
class Stack {
[Code] .....
View 1 Replies
View Related
Jul 15, 2013
I have two vectors of float that I need to sort in reverse order. reverse() seems to work for one of them, but not the other. I have toggled between sort() and reverse(). for one vector, the expected behavior is seen and the order reverses. For the other, there is no change in order.
This is very simple code, so it's hard to imagine what is going wrong.
Code:
vector<float> vec1, vec2;
vec1[0] = 14.1102; vec1[1] = 14.1145;
vec2[0] = 15.8508; vec2[1] = 26.0842;
sort( vec1.begin(), vec1.end() );
sort( vec2.begin(), vec2.end() );
[Code] ......
Printout is,
Code:
vector 1 sort
14.1102
14.1145
vector 2 sort
15.8508
26.0842
vector 1 reverse
14.1102
14.1145
vector 2 reverse
26.0842
15.8508
You can see that the order of the first vector did not change. Am I right in suspecting that the numbers are too similar for what ever method reverse() uses to determine the difference between values?
View 8 Replies
View Related
Oct 30, 2014
I have to modify my output text file and convert every sentence into paragraph. I ran it its copying whole text but not paragraph after dots.
#include <iostream>
#include <string>
#include <fstream>
#include <cctype>
using namespace std;
void copyText(ifstream& intext, ofstream& outtext, char& ch);
[Code] .....
View 2 Replies
View Related
Dec 31, 2013
I'm working on a code that needs to loop a switch case back to the beginning after a certain input is entered.
ex) Code:
printf("Select an option);
printf("1. Play game");
printf("2. Status");
printf("3. Exit");
scanf("%i", &userinput);
switch(userinput);
[Code]...
For my program, I want option 2 to display something, then loop back to "select and option" after the user presses enter. How would I write that? Would i use a while? do while?
View 3 Replies
View Related
May 26, 2013
How can I make the output print out to the screen in reverse?
Code: #include <iostream>
#include <iomanip>
using namespace std;
int getnum();
void Fibonacci(int n);
[Code].....
View 7 Replies
View Related
Nov 4, 2013
I'm working on a project which uses gtk+ and gtkmm. We use them in preference to MFC because the program needs to be cross-platform. For quite a long time, customers on OS-X and Linux have sometimes complained that the program would crash during shutdown but the Windows version (which I work on) never seemed to suffer. However, I'm now transferring my build environment to a new PC and I'm noticing the same shutdown crashes. It's a bit complicated so let me start with a small example:-
Code:
namespace Whatever {
class B {
public:
virtual ~B();
private:
int bb;
[Code] ....
Suppose I run the above program. When it stops at breakpoint #1 I make a note of the value of pA. Eventually the program reaches breakpoints #2 and #3. At each point my this pointer is exactly the same number. If the value of pA was 0x03604fb0, my this pointer is identical at both stages.
Now let's consider the real example:-
Code:
namespace Gtk {
class Widget {
public:
virtual ~Widget() {}
[Code] .....
Suppose I run the real example. At breakpoint #1 the value of pW is 0x03604fb0. But by the time I reach breakpoint #2 my this point is slightly different:- 0x03604fcc. It doesn't seem right to me and I'm wondering if it might be contributing to our shutdown crashes.
View 6 Replies
View Related
Nov 10, 2012
My assignment is to create a C++ Program to find the sine of a number without any library other than iostream by using Taylor Series:
sin (x) = (x/1!) - (x^3/3!) + (x^5/5!) - (x^7/7!) + (x^9/9!) ...... (x^n/n!).
Here is what i have done till now:
#include <iostream>
double fact (int f); //declaration of factorial function
double power(double x, int y); //declaration of power function
double sin(int x); //declaration of sine function
//double cos(int x); //declaration of cosine function
//double tan(int x); //declaration of tangent function
[code]....
View 3 Replies
View Related
Feb 11, 2013
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
How to read sentence from Command line with MFC?
View 5 Replies
View Related
Oct 31, 2013
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
}
[code]....
View 5 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
Oct 18, 2013
The program keeps on crashing when it finishes case 1
View 5 Replies
View Related
Feb 13, 2015
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.".
View 7 Replies
View Related
Feb 20, 2014
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).
View 2 Replies
View Related
Apr 18, 2013
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;
[Code]....
View 6 Replies
View Related
Apr 16, 2015
I want to get ride off lists and vectors in this program i also don't want to use classes, just want to use strings functions and structures...
#include <iostream>
#include <string>
#include <list>
using namespace std;
struct contact {
string name;
int studentiD;
[Code] ....
View 1 Replies
View Related
Nov 3, 2014
Explain this program to reverse an input string:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main() {
void reverse(void);
clrscr();
reverse();
[Code] ....
Do not assume i know about getchar and putchar.
View 2 Replies
View Related