answersLogoWhite

0


Best Answer

Char 'a' is 97 decimal (61 hex) while char 'A' is 65 decimal (41 hex), a difference of 32 decimal (20 hex). Therefore test each char value in the char array (or string) using a for loop. If the char value is in the range 'a' to 'z', then subtract 32 decimal (20 hex).

The following example demonstrates the method:

void toupper(char* str, int len)

{

for(int i=0; i<len; ++i)

{

if(str[i]>='a' && str[i]<='z') str[i]-=32;

}

}

To convert from upper to lower case, use the following instead:

void tolower(char* str, int len)

{

for(int i=0; i<len; ++i)

{

if(str[i]>='A' && str[i]<='Z') str[i]+=32;

}

}

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

Subtract 32 from each character in the range 'a' to 'z', inclusive. C++ will convert these literals to their equivalent ASCII code. Note that ASCII code 'A' is 32 less than ASCII code 'a'. Decimal 32 is 0x20 in hexadecimal notation, and 0x40 in octal.

To convert to lowercase, add 32 to characters in the range 'A' to 'Z', instead.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

#include<stdio.h>

main()

{

char str1[]="PIYUSH";

char str[20];

str2=strlwr str1;

printf("%s", str2[30]);

}

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

If the character is greater than or equal to 'a' and less than or equal to 'z' then subtract 32 from the character. Note that 'a' is ASCII code 97 while 'A' is 65, therefore 97-65=32.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Sure. But it would be more correct to say 'lower case letters' and 'upper case letters'.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

void ToUpper (char* string) {

while (*string != '\0') {

if (islower(*string)) *string = toupper(*string);

}

++string;

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

toupper()

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How to Change lower case to upper case in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

If the frequency in AM does not change then how are these sidebands formed?

The process of changing the amplitude of the "carrier" so as to add information to it (modulation) doesn't change the frequency of the carrier. But it does create energy at two other newfrequencies.The new frequencies are equal to (carrier frequency) plus and minus (the modulating frequency). These are referred to as the upper and lower sidebands.The upper sideband is an exact copy of the modulating signal, but with every component of it shifted up by an amount equal to the carrier frequency. The lower sideband is a mirror image of the upper sideband, with every frequency component in it reflected about the carrier frequency.


Why you use small letter in c or c plus plus programming language?

I assume you mean using lower case letters. By convention, C and C++ standard libraries use lower-case naming conventions. This makes it easy to identify functions and types that belong to the standard library. When defining your own types, a leading capital is preferred. All capitals typically denotes a macro definition.


Is c plus plus language case sensitive?

Because when have varialbles var1 and Var1, they are actually different variables. The same ides with operators, data and so on .


How do you change the Borland C plus plus application icon?

Change the icon in the application's resource file, then recompile.


What is the code to change the font of the output in c plus plus?

There is no generic code to change the typeface of the console output, nor indeed any output window. To change the typeface you must use platform-specific code. That is, the code required to change the output typeface in Windows is completely different to that of Unix-based systems.

Related questions

X plus 4 equals x plus 4 is an example of what property?

Assuming that there is no significance in the first X being upper case and the second in lower case, it is an IDENTITY.


What is the C program to print strings from A to Z and a to z?

#include&lt;stdio.h&gt; int main (void) { char upper[27]; // A-Z plus null terminator char lower[27]; // a-z plus null terminator char c; int i; for (i = 0, c = 'A'; c &lt;= 'Z'; ++c, ++i) { upper[i] = c; lower[i] = c - 'A' + 'a'; } upper[i] = 0; // null-terminator lower[i] = 0; // null-terminator printf ("%s\n", upper); printf ("%s\n", lower); return 0; }


C plus plus program to print sum of uppercase digits?

Good luck. I don't think it is possible, since there is no such thing called upper case digits.


If the frequency in AM does not change then how are these sidebands formed?

The process of changing the amplitude of the "carrier" so as to add information to it (modulation) doesn't change the frequency of the carrier. But it does create energy at two other newfrequencies.The new frequencies are equal to (carrier frequency) plus and minus (the modulating frequency). These are referred to as the upper and lower sidebands.The upper sideband is an exact copy of the modulating signal, but with every component of it shifted up by an amount equal to the carrier frequency. The lower sideband is a mirror image of the upper sideband, with every frequency component in it reflected about the carrier frequency.


Additive inverse of -12?

Additive inverse means that you are supposed to change the sign:* If there is a plus sign (or no sign at all), change it to a minus. * If there is a minus sign (as in this case), change it to a plus (or no sign).


What is the conjugate of 6-5i?

The idea here is to change the sign before the imaginary term. In this case, since there is a minus, you change it to a plus.


What means c plus in piano?

If you see C+ in relation to piano music, it USUALLY means the key of C major or a C major chord. By contrast, you could also see c- meaning C minor. Upper case is usually used with the major and lower case for minor. Unfortunately, the plus sign is also sometimes used to mean C augmented (which is why I use the term"aug" or "x" to denote an augmented triad).


What is the additive inverse of -0.125?

To find the additive inverse of any number, just change the plus sign (or no sign) to a minus sign, or (as in this case), if there already is a minus sign, change it to a plus sign (or no sign).


Solve xx plus 1 equals 0?

x = the square root of -1, an imaginary number written as a lower case italic i.


What is seven-twelfths plus seven twelfths?

If the denominator (the lower part of the fraction) is the same you just add the numerators (the upper part) and place the result over the common denominator.


What is -16t2 plus 70t - 65?

There are no integer roots of this equation. Using the quadratic formula gives roots of 1.34 and 3.04 plus or minus loose change in each case.


Why you use small letter in c or c plus plus programming language?

I assume you mean using lower case letters. By convention, C and C++ standard libraries use lower-case naming conventions. This makes it easy to identify functions and types that belong to the standard library. When defining your own types, a leading capital is preferred. All capitals typically denotes a macro definition.