Jump to content

Lower or higher case ?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
28 replies to this topic

#1
ahmed

ahmed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
I want to make a program in which if I input A it should print that its a capital letter and if i input small a it should display small character , how can i write this?and also a program which inputs 4-5 numbers and prints the highest number and the lowest number?so any help ?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Because a character is represented internally as an integer, you can test whether it is between 'a' and 'z' or between 'A' and 'Z'.

You have to go through the inputs and keep track of the current low/high number.

If you show us your code, we can help you further.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
dcs

dcs

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 775 posts

ahmed said:

I want to make a program in which if I input A it should print that its a capital letter and if i input small a it should display small character , how can i write this?
isupper and islower

ahmed said:

and also a program which inputs 4-5 numbers and prints the highest number and the lowest number?so any help ?
Take a stab at it first.

#4
ahmed

ahmed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
is this correct ?
#include<conio.h>
#include<iostream.h>
#include<ctype.h>
void main()
{
char alphabet;
clrscr();
cout<<"\n Enter Alphabet : ";
cin>>alphabet;
if(alphabet==toupper(alphabet))
cout<<"\n It is CAPITAL";
else if(alphabet==tolower(alphabet))
cout<<"\n It is SMALL ";
getch();
}


#5
amrosama

amrosama

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 8,674 posts

#include<conio.h>

#include<iostream.h>

#include<ctype.h>

int main()

{

char alphabet;


cout<<"\n Enter Alphabet : ";

cin>>alphabet;

if(alphabet==toupper(alphabet))

cout<<"\n It is CAPITAL";

else if(alphabet==tolower(alphabet))

cout<<"\n It is SMALL ";

return 0;

}


yes its true with a small fix

#6
dcs

dcs

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 775 posts
Are you stuck learning on the ancient Turbo C++, ahmed?

#7
Steve.L

Steve.L

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 444 posts

WingedPanther said:

Because a character is represented internally as an integer, you can test whether it is between 'a' and 'z' or between 'A' and 'Z'.

You have to go through the inputs and keep track of the current low/high number.

If you show us your code, we can help you further.

Wow this looks familiar...

#8
Guest_Jordan_*

Guest_Jordan_*
  • Guests
A link that may help if you want to compare the integer values (as Winged states): Ascii, Decimal, and Hexadecimal Conversion Chart

#9
Steve.L

Steve.L

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 444 posts
I posted this method in his previous thread and was shot down for it. What's the difference in this case?

#10
dcs

dcs

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 775 posts
I hadn't gotten around to it yet?
http://forum.codecal....html#post90057
http://forum.codecal....html#post90354

#11
ahmed

ahmed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
I got this program working , yup i am using turbo C++ trying to get on visual c++ 6.0 , anyways how can i compare 4-5 numbers and get the largest and smallest?

#12
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,710 posts
Use a for loop with two variables, one to hold the smallest, and one to hold the largest. Compare the input to them; if the input is smaller than the smallest, change the variable containing the smallest. If the input is larger than the largest, change the variable containing the largest.