473,473 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Tell me the Ans

2 New Member
Q.1>Write a program to print the following output
using for loops
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
.....................

Q.2> Write a function using reference variables as arguments to swap the values of a pair of integers.

Q.3>Write a function that creates a vector of user given size M using new operator
Feb 21 '08 #1
6 5973
Simonius
47 New Member
We don't just give code.
Show what you've attempted so far.
Feb 21 '08 #2
Ganon11
3,652 Recognized Expert Specialist
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

Please read the Posting Guidelines and particularly the Coursework Posting Guidelines.

Then when you are ready post a new question in this thread.

MODERATOR
Feb 21 '08 #3
billyusa
5 New Member
i have similar problem with that of hers

Assume that the int variables i , j and n have been declared, and n has been initialized. Write code that causes a "triangle" of asterisks to be output to the screen, i.e., n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consisting of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be (scroll down if necessary):
*
**
***

my work is as how

for (i=1; n <=j; i++)
{cout << n - (i * 2);
cout << n - i;
cout << n + j;

}
please help as I really dont understand this stuff, and teacher doesnt explainw ell and book we use is of no use as it just covers same topic from chapter 1 ofver and over giving no real help


thanks in advance
Feb 23 '08 #4
Simonius
47 New Member
Your logic is a bit faulty.

This should do the trick

Expand|Select|Wrap|Line Numbers
  1. for(i = 0; i < AmmountOfRows; ++i){
  2.         for(j=0;j<i;++j)
  3.             cout<<"*"
  4.         cout<<endl;
  5. }
  6.  
This is basicly your logic:
You want to loop untill you have the desired ammount of rows, that's the first line.
Then you want to make a loop that prints a * untill there are as many stars on that line as the line number. That's the second and third line of coding.
Then after all the stars for that line are printed you need a new line, that's the fourth line.

This is just a basic usage of loops.
If you can't figure it out I suggest trying to write down what you need to do, or imagine what you want the completed program to do if you step through it.
Feb 23 '08 #5
billyusa
5 New Member
thanks i got it down I think,
Feb 23 '08 #6
angellove40
2 New Member
Thanks Buddy [b],
Its really worked i just put "i" instead of * and my prob got solved.
Feb 24 '08 #7

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

Similar topics

3
by: Jonathan | last post by:
Rather than me explain the problem, read this exchange of emails between my web host and myself, then tell me what I can tell them! I had a problem with their admin site all day, and after me...
8
by: Peter Abel | last post by:
Hi all, I'm working under W2k with Python 2.2.2 (#37, Oct 14 2002, 17:02:34) on win32 I have a file *test_data.txt* with the following content: 0123456789 0123456789 abcdefghi...
3
by: Pernell Williams | last post by:
Hi all: I am new to Python, and this is my first post (and it won't be my last!), so HELLO EVERYONE!! I am attempting to use "xreadlines", an outer loop and an inner loop in conjunction with...
3
by: N. Volbers | last post by:
Hello everyone, I noticed that when you open a zipped tarball using 'tarfile' and if you then get the pseudo-file descriptor fd for a file via 'extractfile', then fd.tell() is broken in the...
1
by: jazzMan007 | last post by:
Hi All - I'm using the new UrlMappings feature in an ASP.NET 2.0 application. I'm using the unique urls, mapped to shared files, in the site map. So for example, I have pages A, B, & C...all of...
13
by: Jiho Han | last post by:
Here's the issue. You have a class, Class Person { public int id; public string firstname; public string lastname; }
3
by: sara | last post by:
Hi - I have a button that runs 2 reports. If there is no data on the report, I use the No Data event, and tell the user, and Cancel the execution of that report. However, if the first report...
3
by: Magdoll | last post by:
I was trying to map various locations in a file to a dictionary. At first I read through the file using a for-loop, but tell() gave back weird results, so I switched to while, then it worked. ...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...
0
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...
1
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...
0
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...
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.