473,597 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asterisk algorithm

joewin
2 New Member
Guys, help me.
Give me some hints on how to do this program . . .
a program that will print an asterisks and zeroes one-at-a-time and will to print like the following pattern.

**0**

*0*0*

0*0*0

*0*0*

**0**
Mar 2 '17 #1
2 1771
weaknessforcats
9,208 Recognized Expert Moderator Expert
You could always:

printf("**00**\ n");

and use a separate printf for each pattern.

If you can't do this, then there must be some required things left out of your problem description

Are you using C or C++?
Mar 2 '17 #2
dev7060
644 Recognized Expert Contributor
Yes, the above pattern can be printed using output statements. However, you may also use loops for this. Try to mention your approach/code you are using.

Some idea: In the 2nd line, you can observer that 0s are present at even places [*2*4*] and in the 3rd line at odd places [1*3*5] etc. So, declare an array of length 5 and use the modulus operator to check for even and odd places and assign the value of 0 to them, the rest of the array can contain *.
Mar 3 '17 #3

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

Similar topics

3
4128
by: sarmin | last post by:
Hi Pythoners... It seems to me the Asterisk (*) sign in python means many things... if a python code line looks like this: def__init__(self, func, *param): bla bla bla... and then u have something like this: func(*param)
1
2543
by: sarmin kho | last post by:
Hi Pythoners... I am definitely confused with the use of asterisk (*) sign in python... I quoted the following code from 'python cookbook' text book page 223 about 'running functions in the future'... it says: def __init__(self,func, *param): bla bla bla... then it says:
2
2670
by: Marco | last post by:
Hi all, I saw the following line in a C source. what's the asterisk * mean? Thank you! fprintf(conn_out, "%.*s\r\n", (int)(strlen(buf + 1) - 1), buf + 1);
3
1463
by: Robert M | last post by:
Hello, I am having a problem when I enter a new row using data grid footer and the data contains asterisk ('). I can use replace function, and it will not crash the program but it shows 2 asterisk (' '). Actually it does not happen in all footers and I can not find what is the difference, unless I turn some property true... Help is very much appreciated Thank u
2
2602
by: Evan | last post by:
I am trying to put an asterisk in the Label text property but the asterisk doesn't show up in the correct place. If I enter "* hello" in the text property (using the designer property pages) the label is displayed as "hello *". If I enter "3 * hello" the label is displayed as "hello * 3". How I get the asterisk to display in the proper location? Thanks in advance.
4
3648
by: deepee | last post by:
I have a drop down box in HTML using SELECT and OPTION tags: <select title="Choose a number" onchange="obscure()" name="Digit1" ID="Digit1"> <OPTION VALUE="">&nbsp;</OPTION> <OPTION VALUE="0">&nbsp;0</OPTION> <OPTION VALUE="1">&nbsp;1</OPTION> <OPTION VALUE="2">&nbsp;2</OPTION> <OPTION VALUE="3">&nbsp;3</OPTION> </select>
0
1496
by: selvarani | last post by:
Hi all, I am a newbie to Asterisk and PHP. I have installed wamp5_1.4.3 and working with PHP on this. I would like to write a PHP script to interact with asterisk. Where are the Manager API's used. How come the PHP script and Asterisk Manager API's interact? What should the script do exactly? Anyone help me out. Thanks in advance.
1
18980
by: striker07 | last post by:
Someone help me how can i display a diamond shaped asterisk correctly pls. correct my program this is my code: Dim ctr, space, asterisk As Integer For ctr = 1 To 9 Step 2 For space = (9 - 2) / 2 To 0 LstDisplay.AddItem (" ") Next For asterisk = 1 To ctr
2
9143
by: Coll | last post by:
I'm working with a form & a query that allows the user to filter the data using several combo boxes. One of the combo boxes allows them to select the first letter of a a particular field, and it will use that first letter in the criteria of the query to include only records with a value beginning with that letter. The tricky part is that one of the possible values for that field is - *.* - not values I would have chosen, but they are...
0
7886
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
8258
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...
0
6688
agi2029
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...
1
5847
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
5431
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
3927
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2404
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
1
1494
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1238
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.