Hello mates.
I am taking my very first programming language (C Programming) and as for practice purposes, I surf sites and try out to make programs. I am having problems with the following C Programming problem.
1) You are required to use at least one for() loop to control the printing of a table in this lab.
2) Do not use the scanf() function in this lab, use the getchar() instead.
3) Your table will consist of three data type representations for each value. The data types are decimal, hexadecimal and the character itself.
4) Present column headers as shown in the output below.
5) Group those three columns together to form one main unit, that unit has to be repeated two more times going horizontally across the screen. After you have printed the unit three times, start a new line.
6) Every twenty lines stop the output and prompt the user to "Hit any key to continue...". Be sure to repeat your column headers again, as shown below.
The range of the table is defined by the two values input by the user at the start of the program.
7) Pay careful attention to how the data in the columns lines up vertically.
8) If the character is between 7 and 13 (inclusive), print the decimal and hexadecimal values only, do not print the character, just print a space instead.
Sample Output
Enter starting character: a
Enter ending character: z
D H C D H C D H C
-----------------------------------------
97 61 a 98 62 b 99 63 c
100 64 d 101 65 e 102 66 f
103 67 g 104 68 h 105 69 i
106 6a j 107 6b k 108 6c l
109 6d m 110 6e n 111 6f o
112 70 p 113 71 q 114 72 r
115 73 s 116 74 t 117 75 u
118 76 v 119 77 w 120 78 x
121 79 y 122 7a z
-------------------------------------------------------------------------------------------------------------------
This is my program so far:
#include <stdio.h>
#include <ctype.h>
int main(void)
{
int start;
int end;
int i;
printf("Enter starting character: ");
start = getche();
printf("\nEnter ending character: ");
end = getche();
printf("\n D H C D H C D H C");
printf("\n-------------------------------");
for (i = start; i <= end; i++)
{
while (1)
{
if (start >= 7 && start <= 13)
{
printf("\n%3d %2x", start, start);
}
else
{
printf("\n%3d %2x %c", start, start, start);
}
start = start + 1;
break;
}
}
}
-------------------------------------------------------------------------------------------------------------------
I can give the output right but I can not make it come out in columbs of 3 as it should. Neither do I understand how to break the output after every ouputs.
Help would be appreciated.
Regards
Khizer
2 2763
My friend first try to initialize numbers or characters to start and end because your second expression does not work...The one with asking end character.
I am quite confused also with your question.If it is appropriate please try to make it a little more clear to understand.
then i am ready for help whatever i can
Start and End are initialized by the user with the getche() command. The 'i' value is intialized in the for loop.
I ran the program and it worked for me alright. Just copy and paste it in notepad and run it in dos. Its a C program and not a C++ Program.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Joh |
last post by:
hello,
i'm trying to understand how i could build following consecutive sets
from a root one using generator :
l =
would like to produce :
, , , ,
|
by: mr.iali |
last post by:
Hi Everyone
I would like to get into software developent using a programming
language like c++, java or pl/sql for oracle.
I have no idea where to start from. Which language is there more demand
for. Looking at jobs there seems to be a better chance in getting a
java job rather than a oracle or c++ job.
Also is java and oracle a good combiantion?
|
by: G. |
last post by:
Hi all,
During my degree, BEng (Hons) Electronics and Communications Engineering, we
did C programming every year, but I never kept it up, as I had no interest
and didn't see the point. But now I really want to get back into it as I see
a point with GNU/Linux. I want to get my old skills back and write something
or help on some projects etc.
I need some good books. I used to have one called "A Book On C", but sold
it,
|
by: hzmonte |
last post by:
typedef int t_compare_func(const void *, const void *);
struct node *tree_search(struct node *root, const void *keyy,
t_compare_func *comp)
{
struct node *cur_item;
int result;
if (root == NULL) return NULL;
cur_item = root;
while (cur_item != NULL) {
|
by: Dale |
last post by:
I've searched Amazon and read probably 100 reviews but can't find what seems
to be any book that is widely accepted as the definitive book on object
oriented programming design and techniques. And most of the highest rated
are all written 10 to 15 years ago. Any good suggestions?
| |
by: John Salerno |
last post by:
There is an article on oreilly.net's OnLamp site called "The World's
Most Maintainable Programming Language"
(http://www.oreillynet.com/onlamp/blog/2006/03/the_worlds_most_maintainable_p.html).
It's not about a specific language, but about the qualities that would
make up the title language (learnability, consistency, simplicity,
power, enforcing good programming practices). I thought this might be of
interest to some of you, and I...
|
by: Ray |
last post by:
OK, maybe I shoot a more general question to the group since there are
so many great programmers here: how do you practice your craft?
I do it in the following way:
1. Set aside 30 minutes to 1 hour a day to read up on the latest
development, be it about the tool I'm using, the language, or the
platform, or the framework, etc.
2. Once every 1-2 months, go to Amazon, and look for the book with the
|
by: antoan |
last post by:
Hi,
I am looking for C# practice/interview programming problems and NOT
general framework explanatory questions.
The ones I've come across I find a wee bit easy. I'd like to find
material that tests not just technicality or knowledge of the language
but also one's problem solving abilities, though not the kind that takes
a day to implement a piece. I'd be grateful to ya'll for any
recommendations on books/link/resources that you might...
|
by: Michael |
last post by:
Hey, I'm, I guess, an itermediate programmer and I have a question about
learning any programming language. I understand that as a programmer you're
going to probably constantly be re-writing code and the best method would be
to save a template or other etc. I also know that it's ok to use other
people's code to help you do something, but wouldn't it be best to re-type
the code or study it until YOU learn how to do it and you actually...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |