473,324 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

can anyone tell me the code for this?

4
write nested loops (while or for) to print a trun-
cated (missing a few lines at the top) triangular figure using
integers m and k. This figure is made up of stars and spaces. First
choose smaller of m and k, and call it top. Call the other number
height. For this truncated triangle, top tells you how many stars
(`*') are there on the top line. Height tells you, how many lines are
there. For the above example, m = 3 and k = 6 So top is 3 and height
is 6. Now print a truncated triangular figure of stars (*) as shown.
Here top line has 3 stars and truncated triangle has 6 lines.

m = 3, k = 6, top = 3, height = 6

***
*****
*******
*********
***********
*************
Oct 6 '06 #1
4 1828
try the code given below and let me know the result
for (i=1;i<=k;i++)
{
for (j=1;j<=m;j++)
cout<<"*";
cout<<endl;
m+=2;
}
Oct 6 '06 #2
vp1
4
thanks.but its not giving the truncated form.
**
****
like the above one.with every line two spaces are decreasing and a stars are increasing.
Oct 6 '06 #3
it is working fine on my side can you please give the code
Oct 6 '06 #4
D_C
293 100+
Expand|Select|Wrap|Line Numbers
  1. for (i=1;i<=k;i++)
  2. {
  3.   for (j=1;j<=m;j++)
  4.   {
  5.     cout<<"*";
  6.   }
  7.   cout<<endl;
  8.   m+=2;
  9. }
is how it should look. Maybe the whitespace was lost and you put more into the nested for loop than there should be?
Expand|Select|Wrap|Line Numbers
  1. for(int i = 0; i < k; i++)
  2. {
  3.   cout << string(m,'*') << endl;
  4.   m += 2;
  5. }
should do the same thing.
Oct 6 '06 #5

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

Similar topics

5
by: Dhruv | last post by:
I'd like to know if anyone had some sort of code like parent_ptr that I could use. Let me just describe what I'm looking for. It's kinda a hybrid between auto_ptr, and shared_ptr. You can specify...
4
by: Hai Nguyen | last post by:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using panel to test myself. I tried to use these code below, which is written in VB, and to transform them to c sharp but I got...
29
by: Roy Gourgi | last post by:
Hi, I am new to C#. I have the same time scheduling program written in C++ and it is 5 times faster than my version in C#. Why is it so slow as I thought that C# was only a little slower than...
0
by: Mike | last post by:
Hi All, I am using a COM object and so I have to use a form for it to work. The problem is I need to run it as a service as well. When I run it in a test scenario everything works fine and...
33
by: O-('' Q) | last post by:
....to translate the following to C#.NET style? var i: Integer; begin txtMyIP.Lines.Clear; sHTML := HTTP.Get('http://www.network-tools.com/'); if sHTML = '' then Exit; sIpAddr := 'IP...
4
by: ImOk | last post by:
I have the following setup: Windows XP Prof, IIS, PHP5 PHP5 works no problem with either PHP-CGI.EXE and mySQL, PHP5 also works no problem with php5isapi.dll as long as I dont use mySQL....
4
by: Bruno Alexandre | last post by:
Hi guys, I'm using the asp:menu component and everything worked great in my machine, but when I upload the files to our Hosting I got this: http://portal.filterqueen.dk/portal2.fq/test.aspx ...
4
by: doc | last post by:
Anyone tell me about patServer please. Does anyone know where I can find instructions on how to use patServer - spent ages on the net trying to find a 'how to'. Specifically, where to put each...
2
by: aling | last post by:
I create ASP.Net 2 website project in VS 2005, but the solution file always uses absolute path in PhysicalPath attribute. I want to copy the website project anywhere, so the absoluted path not...
3
by: xhe | last post by:
I found Jason is a very handy data format for client/server communication. But I just met a problem as follows: I want to read the data replied from server in Jason format, the reply is like...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.