473,657 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can I write a given SENTENCE in triangle ?

2 New Member
Hi , can anyone help me about writing a given sentence in Floyd's triangle .

e.g ,

printf("Write a sentence:\n");

sentence=getcha r(); ( I should not use arrays , functions,point ers)


and as a sentence this one is given , e.g. helloworld!

W
WW
WWW
WWWW
WWWWW
WWWWWW
WW+++++++

and if the triangle is not filled with letters of the sentence, it should be filled with + .


IS ANYONE THAT CAN HELP ME ABOUT THAT ...
Nov 15 '09 #1
4 3700
Markus
6,050 Recognized Expert Expert
You're going to have to explain the question a little more as I didn't understand one bit of it.
Nov 15 '09 #2
xhani
2 New Member
Using of arrays,pointers ,functions is forbidden

In this code I should take from user a SENTENCE and save it in a Char Variable.
User after writing the sentence can type '#' to end the input. After the user enters the sentence,it can be with (commas ',' duts'.' and space' ' ) .Then I should do the functions for counting how many words, how many sentences... I've done whole the code. Just one part is missing. Writing that given sentence in FLOYD's triangle.

printf("Type a sentence,to end type #:\n");
sentence=getcha r();

while (sentence!='#') {
/*I did the functions for counting words,sentences ,then just
the printing part of FLOYD's triangle shape of sentence is missing

**** if we think that user writes this sentence ,"Hello,toda y Im gonna solve it.#"

the triangle should be like this ..

h
el
lo,
toda
yImgo
nnasol
veit.++ And if the Triangle shape is not correct, to be well-shaped the
the missing part should be filled with '+'

:)
Nov 15 '09 #3
spiralfire
8 New Member
@xhani
write a loop, and keep an int, starting on "1". this will be the number of chars you will be printing, and an int that keeps the amount of chars you already printed.

so:
Expand|Select|Wrap|Line Numbers
  1. while( bool value )
  2.    the for here (numbers of chars to print on current line)
  3.       print one char
  4.       increment amount of chars printed
  5.       if you have printed all chars from the sentence
  6.          loop here to print the '+' you need.
  7.          break from the inner loop (for) and outter loop (while) setting the while condition to false, so it won't loop anymore
  8. end
  9.  
i think this will solve it, now write some c code!
Nov 15 '09 #4
Banfa
9,065 Recognized Expert Moderator Expert
Actually I think its impossible using C standard library functions.

How will you store the sentence if not in an array (which are forbidden)?

You can't take direct input because all C standard library functions echo the data input and that would muck up your formatting.

Actually while typing that sentence I thought of the solution. It involves taking advantage of the input character echo and just outputting newline characters at the relevant times (character positions). Then at the end of the sentence (the '.') outputting the correct number of '+'.

spiralfire your solution will not work because although you have print char I assume you mean character of the sentence but to do this you must specifically not print any characters of the sentence and also you never print any newlines which are the one thing (apart from possibly '+') that you must print.
Nov 15 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

16
50438
by: VISHNU VARDHAN REDDY UNDYALA | last post by:
Hi, Could anyone over here, write a program in C using only for loop to print the following output * *** ***** ******* ********* ***********
0
2338
by: Angela | last post by:
I am using VS.NET 2003 and Crystal 9. I have been told by Crystal, as well as many co-workers who know Crystal really well, that I cannot create the particulat graph I need using Crystal Reports. Here is an example of the kind of data I am trying to graph: Question: How much TV people watch a day? Responses (as a percentage of total responses): > 2.0 hours = 60% 2 - 4 hours = 30% < 4 hours = 10%
2
1933
by: javadkhan | last post by:
Hi All, I am trying to supress the small black triangle that shows up in the menus meaning the menuitem is parent. The reason for that is I drew my own 3D looking triangle in DrawItem using GraphicPath glyph. What I have right now is my 3D triangle and default windows menu triangle on it. My question is, is it possible to hide this default triangle or send it behind mine or some other way of doing this?
4
2740
by: bennett | last post by:
How can I do a loop from 1 to 5, where on line 1 I print 1 space followed by a button, on line 2 I print 2 spaces followed by a button, on line 3 I print 3 spaces followed by a button, etc.? I tried this code: for (int i = 1; i <= 5 ; ++i) { for (int j = 1; j <= i; ++j) {
1
3340
by: Leo | last post by:
Can someone tell me how to make the sorting triangle on datagrid column header always show up? And which property can change the color of the triangle ? The default color is white. Thanks
19
8255
by: lost1 | last post by:
Can someone point me in the right direction on how to get the triangle type to display. Below is a triangle class that is tested by another completely separate class. The main method of the test class executes the code you see below. What I'm trying to figure out is what I'm doing wrong in getting the triangle type to print. the integers typed in by the user print fine, but I keep getting "null" for the triangle type because I don't know how...
10
2146
by: cjard | last post by:
I have a client and server that enjoy the following simple dialogue: Client connects Client sends request Server sends response Client disconnects This is the way it must be. The response must be wrapped in a start and end byte 0x02 and 0x03 resepctively.
6
13353
by: jackj | last post by:
Hi, I am first time C++ student and doing the usual tasks. This one is to create a triangle based on user input of how large (how many rows) and what symbol to use. I have managed to create a triangle that aligns to the left of the screen, but it loops and disappears immediately. So, my problem is getting it to stay on the screen and then ask the user if they want to create another one AND to make it print the first symbol in the center of...
14
16264
by: ginevralupin | last post by:
Puhleeeease check this ....... Isnt giving the correct output ... int a,b,c; printf("Enter the sides..."); scanf("%d %d %d",&a,&b,&c); if (a<(b+c)) printf("The triangle is valid."); else if (b<(c+a))
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8613
tracyyun
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...
1
6176
isladogs
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...
0
5638
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();...
0
4173
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...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.