C :: Converting Two Strings To Upper And Lower Case Using Function

Dec 6, 2014

My code so far

Code:

#include <stdio.h>
#include <ctype.h>
#include <string.h>

[Code]....

I keep getting these 3 errors :

error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|.
error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|.
error expected '{' at end of input|.

View 4 Replies


ADVERTISEMENT

C :: How To Get Upper Case And Lower Case Equal

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

C :: Way To Check If Letter Is Upper Or Lower Case

Jul 7, 2014

can i do in this way to check if letter is upper case or lower case is it better to using casting or i can do without casting.

Code:

if(selectOption == (char)81){
selectOption = (char)113;
}

View 2 Replies View Related

C/C++ :: Converting String To Upper Case Via Dynamic Array?

May 21, 2014

I am trying to understand why i keep getting errors in my code. The errors are after the string is converted in my console window. I have to allocate and delete memory via dynamic array to do the problem.

#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main() {
string sentence;
int size;

[code]....

I just want to know why the extra characters are at the end of my conversion and how to make them stop.

View 3 Replies View Related

C++ :: Modify Contents Of 1D Character Array - Converting To Upper Case

Feb 10, 2015

I am unsure how to write a function which modifies the content of the 1D character array and puts all of the letter it contains into uppercase. the following are the letters which i am trying to convert.

char text[MAX+1] = {'T', 'e', 's', 't', 'e', 'r', EOT};

The output to this should look like T E S T E R EOT

View 2 Replies View Related

C++ :: Function To Change Char Array String To Lower Case

Feb 17, 2014

This code ran well until i added in the ToLower function which is supposed to convert the char array string to lower case (based off ascii strategy -32). correct this function so it converts string to lower case and doesn't get errors.

#include <iostream>
#include <string>
using namespace std;
const int MAX = 81; //max char is sting is 80
void ToLower(char s[]);
int main(){
string y_n;

[Code]...

View 1 Replies View Related

C++ :: Enter Name Of Your Favorite City In Lower Case

Oct 1, 2013

Please enter the name of your favorite city in lower case: (user for example enters) chicago

chicago is supposed to be data entered by the user.

My question is what code should i enter to enable the user to enter such data and how can i use that data (chicago) with the rest of my code.

View 6 Replies View Related

C# :: Upper Pyramid Is Working Fine But Lower Pyramid Executes Infinite

Feb 10, 2015

I need to print like below pattern.

1
121
12321
1234321
123454321
1234321
12321
121
1

I got the upper pattern but below pattern is not working it executes infinte loop, how to reslove this.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ro {
class ro {
static void Main(string[] args) {
int numberoflayer = 5, Space, Number;

[Code] ....

View 1 Replies View Related

C++ :: Change First Letter Of Each Name To Upper Case?

Oct 2, 2013

I can get the first letter to change if there is only one word. But if there are two words it wont change and display the second word's first letter and I'm not sure why.

#include <iostream>
#include <iomanip>
#include <cstring>

[Code].....

View 3 Replies View Related

C++ :: Convert Input String Into A Form - Capital And Lower Case Letters

Mar 27, 2013

How can I write program that can convert an input string into a form that only the first letter of the string is a capital letter and the rest is lower-case?

View 3 Replies View Related

C/C++ :: Upper Case Conversion And Digit Summing

Feb 23, 2015

Write a program that reads characters from the keyboard using the getch() function. All lower case letters will be converted to upper case and printed out to the display using the putchar() function. All uppercase letters will be printed using putchar(). All individual digits will be accumulated and the sum will be printed at the end of the program using printf(). You will write a function to return the upper case of the letter and a second function which receives the current sum and the character digit.

The convert digit function will convert the character digit to a decimal value and accumulate the digit to the sum returning the new sum. Only the letters will be printed out nothing else. The program will continue until the return is received at which time the sum of the digits will be printed on the next line. What was entered: a9 wF23’;/4i What the line actually shows: aA9wWFiI The sum of the digits is: 18

I dont understand why it expects more () in the functions....

View 11 Replies View Related

C++ :: String Find And Replace (Modified To Upper Case)

Feb 3, 2013

"C++ is a general-purpose programming language." I have to find the word "C++" and replace it with "Java" and then capitalize all letters.

#include <iostream>
#include <string>
using namespace std;
int main( ) {
string origin; //contains input string
string replace; //the string obtained by replacing "C++" with "Java"

[Code] ....

View 1 Replies View Related

C :: Original Text File / Generate Another File With Text Content In Upper Case

Nov 29, 2014

Code software that, from an original text file, generate another file with the text content in upper case.For exemple:

entrence:

luke
tom
alex

outings:

LUKE
TOM
ALEX

My code so far:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
}

[code]....

View 2 Replies View Related

C++ :: Comparison Of Two Strings (case Insensitive)

Apr 27, 2013

bool simpleQuestion::checkAnswer(string guess) const {
for (int i=0;i<qAnswer.length();i++)
if (qAnswer==guess)
return true;
else
return false;
}

This is my code and what im trying to accomplish here is making the comparison of the two strings (qAnswer & guess) case insensitive. I know i need to loop through each character of each string and for each character i can use toupper and every char in each string will become uppercase and therefore case insensitive. However, im not sure how to go about this; if any technique used to loop through each character of the string and how to use to upper.

View 2 Replies View Related

C/C++ :: How To Compare Strings Ignoring Case

Oct 29, 2014

It should report whether or not, ignoring case, they are the same.

#include <stdio.h>
#include <string.h>
using namespace std;

[Code].....

View 1 Replies View Related

C++ :: Converting Strings In Application

Jun 8, 2014

I am having trouble converting strings in my application.

This is the code that is eventually getting called, the first parameter takes a LPCWSTR

Code:
hr = m_pGraph->RenderFile(m_filePath, NULL); // takes LPCWSTR This is where the trouble begins.

The compiler shows that sResult is proper but after I try to convert a std::string to a wchar it prints garbage

Code: const wchar_t* m_filePath = (wchar_t *) oDb->GetNext().c_str();

Code:
std::string CSqlLiteDatabase::GetNext() {
sqlite3_stmt *oStmt = nullptr;
std::string sql = "SELECT path || filename FROM table WHERE id = 1";
char message[255];

[Code] ....

View 6 Replies View Related

C++ :: Converting Strings To Dates

Feb 8, 2014

Code for converting strings to Dates in C++.

Example: What is the date:
User response: 12/05/14

Any way I can code this to recognize it as a date, and make it so that the date is sortable? Not referring to the system date, but a user input date.

View 1 Replies View Related

C/C++ :: Converting BMP To Strings Of 0 And 1 (Binary Format)

Mar 14, 2014

I want to read a Bitmap file in C language and produce the binary equivalent of it in the form of 0's and 1's.

View 1 Replies View Related

C :: Converting Strings In File To Lowercase / Uppercase?

Aug 4, 2013

okay so this program is basically getting the files from user input then reading the original file and convert the string into a uppercase/lowercase form and save it into another file. Is there a way to save the string from the first file to a variable then convertin the string in the variable and copy that onto the new file? So far i have

Code:

#include <stdio.h>
#include <string.h>
int main() {

[Code].....

View 1 Replies View Related

C++ :: Converting Multiple Lines Of Strings To Double

Aug 26, 2014

I am trying to convert multiple lines of strings to double with std::stod .... I used the code found on the website:

#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
int main() {
std::string two_doubles =" 22145.365 -3564789";
std::string::size_type K;
double first = std::stod (two_doubles, &K);
double second = std::stod (two_doubles.substr(K));
}

The string starts with white spaces. I get this error message when compiling:

warning unused variable 'first'
warning unused variable 'second'

How do you convert the two numbers in the string two_doubles to doubles?

View 2 Replies View Related

C++ :: Find Values That Are Higher / Lower Than All 8 Of Their Neighbors

Nov 19, 2014

I have to do a project where a file with 60 rows and 17 columns is stored in an array. The purpose of the project is to find all the "peaks" and "valleys". A peak is considered a number that has a higher value than all 8 of its neighbors, while a valley is a number that has a lower value than all 8 of its neighbors. Here is an example where peaks are bolded and valleys are underlined.

2558632321342150
3245434041323027
3440383936283035
4045424832342932
3939404247492730
3131313232334435

I'm having trouble coming up with the code that will find values that are higher/lower than all 8 of their neighbors.

View 4 Replies View Related

C :: Converting Function Data To Array

Apr 4, 2013

How can I change this function so it stores each of the even integers into an array of integers?

Code:
void sumIntegers ()
{
int num = 0;
int i = 0;

[Code]....

View 1 Replies View Related

C :: Converting For Loop To Recursive Function

Jun 10, 2013

I am working on a problem that requires a nest for loop to be converted to a recursive function. I am going to provide just the code instead of the entire program.

Code:

for (R1=1; R1 <+3, R1++){ //for loop
printf (something);
}
// the recursive function
void loopR1 (int R1, int max){
if (R1 <= max){
printf (something);

[Code]...

when calling the recursive function in main i am using the following statement...

loop r1(1,3)

View 4 Replies View Related

C++ :: Converting Cmdline Into Normal Function So Can Put Into Library

Apr 23, 2013

I need to convert this code into a normal function that can be put into a library.

Code:

#include <windows.h>
#include <stdio.h>
#include <tchar.h>

[Code].....

Like on line 21&22, I need to get the stuff from within the program, not through cmdline.

View 1 Replies View Related

C/C++ :: Converting Int To Double Pointer Outside Main Function

Dec 22, 2014

I have int pointer called p and i want to calculate average.Since average involves using double or float so i am trying to convert this in the function averagetemp. It still gives me an error saying "cannot be converted"...

#include <iostream>
using namespace std;
int* createArray(int n);
int lowesttemp(int *p,int f);
int highesttemp(int *p,int f);
double averagetemp(int *k,double f);
void print(int *p,int lowest_temp,int highesttemp,int average_temp);

[Code] ....

View 8 Replies View Related

C :: Find Closest Upper Value In Array For Any Input Int

Jul 29, 2013

I have this array (assume sorted) and i need to find out the closest upper value for any input int. Example:

Code:

/* bsearch example */
#include <stdio.h> /* printf */
#include <stdlib.h> /* qsort, bsearch, NULL */

int compareints (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );

[Code] ....

So whenever i hit something that is not in the array i would like to know the closes upper value. So for 4 closest upper value is 5, then for 8 it is 12 , for 35 it is 44. how would one do this?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved