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


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 :: 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 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++ :: 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++ :: 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++ :: 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/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++ :: Input String And Then Convert Each 1st Letter Of Word Into Capital Case

Dec 10, 2014

Write a program that inputs a string and then converts each 1st letter of a word in the string into capital case. An example run of the program is shown below:

Enter string: introduction to programming
Output string: Introduction To Programming

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++ :: 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 :: 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

C++ :: Program To Print Upper Half Of Matrix

Jan 3, 2015

This is a program to print upper half of the matrix.

#include <iostream>
using namespace std;
int upperhalf(int n, int apu[n][n]) {
cout<<"The upper half of the matrix is :

[Code] ....

the compiler is giving these errors:-

sh-4.2# g++ -o main *.cpp
main.cpp:4:31: error: use of parameter outside fun
ction body before ']' token
int upperhalf(int n, int apu[n][n])

[Code] ....

I dont know where i am wrong.

View 3 Replies View Related

C# :: Generate Prime Numbers With Considerably High Upper Limit?

Aug 30, 2014

I was investigating for the first time how to generate prime numbers with a considerably high upper limit, around 10^6 or so. I read about sieve's algorithm and tried to implement it using c#, as I had previously brute forced the generation. In Sieve's algorithm, instead of marking the values that were not prime I simply eliminated them, but I don't think that would make any difference. The issue is that my implementation of sieve's algorithm must be wrong, as when I establish the limit as 10^5 I get the following output:

Brute force:
Computation time: 00:00:00.0643539
Sieve's algorithm:
Computation time: 00:00:20:6934223

I have already checked that their generation of primes is correct, but I do not know why one is significantly slower than the other. Here is my code.

using System;
using System.Collections.Generic;
using System.Linq;

[Code].....

View 5 Replies View Related

C :: Know If Letter Is Inputted Twice

Sep 23, 2013

how can my program read if a letter is inputted again it prompts "letter inputted already"? heres my code:

Code:

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

[Code].....

View 8 Replies View Related

C :: Capitalize Letter Without Using Arrays

Oct 28, 2014

Can I capitalize first letter of each word without using arrays ? If yes, how can I ?

View 11 Replies View Related

C++ :: Letter Frequency For A Vector

Nov 9, 2013

I am trying to print out the letter frequency of a vector that the user inputs and what number that letter is in the ASCII. I am supposed to say, for example: "w" which is ASCII 119 occurs 2 times. How to do this?

View 1 Replies View Related

C++ :: Replace 2nd Occurrence Of Letter?

Apr 27, 2013

i`m currently racking my brains out over this issue. How do i go about the x as the first occurrence of the letter?

lets say helxo , x is the 2nd occurrence of l. I will want to change back x into l

i have replaced it with x in the earlier step with this code...

string everySecondChar(const string &s,char source,char distance)
{
string t(s);
for(std::string::size_type even =0,pos=t.find(source,0);pos!=std::string::npos;pos=t.find(source,++pos))
{

[Code]....

i would like to reverse the process now, letting x becoming l again!

View 10 Replies View Related

C++ :: Letter Frequency Count

Nov 13, 2013

I am new to c++. I am writing a program that reads in a text file and gives a count of how many times each letter appeared in the file. I got it to read the text file and do the letter count. B

X = 102
Y = 126
Z = 165
etc...

THAT IS WORNG

The sample output should be
E = 165
T = 126
A = 102
O = 93
etc...

I got it to sort from lowest to highest for the frequency, but cant seem to get the appropriate letter assigned to it.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

[code].....

View 1 Replies View Related

C++ :: How To Replace 2nd Occurrence Of A Letter With X

Apr 21, 2013

Supposed i have a word hammer.

how am i suppose to search for the 2nd occurrence of the letter and then replace it with x?

example hammer will become hamxer

I thought about using replace for it, however i`m lost on how to find 2 occurrences of the same letter in the word.

string formatEncrypt(string message) {
int msgLength=message.length();
for(int i=0;i<msgLength;i++) {
if(message[i] == 'j' {
message[i]='i';

[Code] .....

at line 31 i tried to put a z into the alphabet that occurs twice.

this is what i have done so far

example: hello world

It will turn out as helzlo world

However i want to make the output appear as helzo world

View 6 Replies View Related

C++ :: Detect If A Letter Key Is Pressed?

May 11, 2014

How would I detect if any letter key is pressed. Would I have to use GetAsyncKeyState() for every letter key? Or could I have some kind of loop going through all the hexadecimal values for every letter? I don't know how I would go through hexadecimal values with a loop.

View 6 Replies View Related

C/C++ :: Determine That Char Is A Letter

Nov 18, 2014

I need to count how many times letter appears in a text. I know that for default letters from 'a' to 'z' and from 'A' to 'Z' there is an interval. But I need also Lithuanian letters, such as ž,č,ę. I wrote this method: (it accepts char code and checks whether that char is a letter)

bool eilutė::YraRaidė(int kodas)
{
if(kodas >= 'a' && kodas <= 'z') {
return true;

[Code]....

As you can see, a lot of checking in switch statement. I use 256 for this reason to have the same effect as unsigned char. But maybe there is a way to shrink down this method, or use some library?

View 7 Replies View Related







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