BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan Right Header

HOME BZU Mail Box Online Games Radio and TV Cricket All Albums
Go Back   BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan > Institute of Computing > Bachelor of Science in Information Technology > BsIT 1st semester > Object Oriented Programming


Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 09-03-2011, 12:13 AM
bonfire's Avatar
M.Arsalan Qureshi

 
Join Date: Oct 2008
Location: Garden Town, Multan Cantt
Posts: 616
Program / Discipline: BSTS
Class Roll Number: 09-31
bonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond repute
Default Program to enter a letter and output the next 2 letters

Program to enter a letter and output the next 2 letters


#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();
char charac;
cout << "Enter your letter : " << endl;
cin>>charac;
cout << "The 2 letters are : " << endl;
cout << (char)(charac-1) << endl;
cout << (char)(charac+1) << endl;
getch();
}
This program takes in a letter charac of the English alphabet as a screen input from the user.
It then determines its previous letter and next letter and prints it out using the 'cout' command.



Sample Input
x
Sample Output
The next 2 letters after x are :
y
z

__________________

Reply With Quote
  #2  
Old 10-03-2011, 12:56 AM
abdkhan's Avatar
Little Baby

 
Join Date: Mar 2011
Posts: 3
Program / Discipline: MSCS
abdkhan will become famous soon enoughabdkhan will become famous soon enough
Default Re: Program to enter a letter and output the next 2 letters

But a good programmer will consider A-z & a-z as characters for a sequence.

The code above will give "[" after Z and '{' after z ,although its a character but it dosnt make any sense .


#include <iostream.h>
#include <conio.h>

void main()
{
{



clrscr(); //This clrscr produces wastege in systems performance
char charac;
cout << "Enter your char : " << endl;
cin>>charac;



cout << "The 2 letters are : " << endl;

if (((char)(charac) <=90 && (char)(charac) >= 66 ) | (char)(charac) <=122 && (char)(charac) >= 98 )// this line can simply be replaced by if (charc != 'a' | charc!='A')
cout << (char)(charac-1) << endl;
else
cout << "There is no char Before "<<(char)(charac)<< endl;



if ((char)(charac) <=89 && (char)(charac) >= 65 | (char)(charac) <=121 && (char)(charac) >= 97 )
cout << (char)(charac+1) << endl;
else
cout << "There is no char After"<<(char)(charac)<< endl;

getch();

}//end main function
}
Reply With Quote
  #3  
Old 10-03-2011, 02:17 AM
bonfire's Avatar
M.Arsalan Qureshi

 
Join Date: Oct 2008
Location: Garden Town, Multan Cantt
Posts: 616
Program / Discipline: BSTS
Class Roll Number: 09-31
bonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond repute
Default Re: Program to enter a letter and output the next 2 letters

Bahi jaan 1 program banay kay kafi ways hotay hain, yahain simple post kia hai. complex program k liyai acha programmer bhi chayai. and u can see that yeh 1st semester k liyai ha. Thanks for reply

__________________


Last edited by bonfire; 10-03-2011 at 02:46 AM.
Reply With Quote
  #4  
Old 10-03-2011, 12:25 PM
abdkhan's Avatar
Little Baby

 
Join Date: Mar 2011
Posts: 3
Program / Discipline: MSCS
abdkhan will become famous soon enoughabdkhan will become famous soon enough
Default Re: Program to enter a letter and output the next 2 letters

ur right, that wa meant for information..After all one has to cover all aspects :D
Reply With Quote
Reply

Tags
enter, letter, letters, output, program


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Program to enter three integers and output the smallest integer using IF bonfire Object Oriented Programming 0 09-03-2011 12:28 AM
Program to enter a character and output its ASCII code bonfire Object Oriented Programming 0 09-03-2011 12:14 AM
Program to enter an integer and output it in the reversed form bonfire Object Oriented Programming 0 08-03-2011 11:59 PM
Program to enter an integer and output its 15 multiples bonfire Object Oriented Programming 0 01-03-2011 03:13 PM
Program to enter three integers and output the biggest integer using IF bonfire Object Oriented Programming 0 01-03-2011 03:11 PM

Best view in Firefox
Almuslimeen.info | BZU Multan | Dedicated server hosting
Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.

All times are GMT +5. The time now is 04:32 PM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.