473,396 Members | 1,712 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,396 software developers and data experts.

Banners

I have to do two exercises out of my textbook which work fine but I have to display a banner before doing the exercises
//March 19, 2008
//Exercise 5.23 and 5.24
//Project 1



#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main()
{
cout<<"Project 1"<<endl;
cout<<"name"<<endl;
cout<<"March 19, 2008"<<endl;
cout<<"Computer Science 111-003"<<endl;
cout<<"Exercise 5.23 and 5.24"<<endl;
cout<<endl;








void print (int any);


int any;
do{
cout<<"Please type in a positive odd integer: ";
cin>>any;
while((any%2==0)||(any<=0));
print(any);
return (0);
}
void print(int any)
{
int spaces=any/1, size=1, counter, count;
for(counter=0;counter!=(any+1)/2;counter++){
for(count=spaces;count>0;count--)
cout<<" ";
spaces--;
for(count=size;count>0;count--)
cout<<"*";
size+=2;
cout<<endl;
}
size=any-2;
spaces+=2;
for(counter=any/2;counter>0;counter--){
for(count=0;count!=spaces;count++)
cout<<" ";
spaces++;
for(count=size;count>0;count--)
cout<<"*";
size-=2;
cout<<endl;
}

system ("PAUSE");

}
Mar 17 '08 #1
1 7022
fual
28
Expand|Select|Wrap|Line Numbers
  1. //March 19, 2008
  2. //Exercise 5.23 and 5.24
  3. //Project 1
  4.  
  5.  
  6.  
  7. #include <iostream>
  8. using std::cout;
  9. using std::endl;
  10. using std::cin;
  11.  
  12. int main()
  13. {
  14. cout<<"Project 1"<<endl;
  15. cout<<"name"<<endl;
  16. cout<<"March 19, 2008"<<endl;
  17. cout<<"Computer Science 111-003"<<endl;
  18. cout<<"Exercise 5.23 and 5.24"<<endl;
  19. cout<<endl;
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. void print (int any);
  29.  
  30.  
  31.     int any;
  32.     do{
  33.         cout<<"Please type in a positive odd integer: ";
  34.         cin>>any;
  35.     while((any%2==0)||(any<=0));
  36.     print(any);
  37.     return (0);
  38. }
  39. void print(int any)
  40. {
  41.     int spaces=any/1, size=1, counter, count;
  42.     for(counter=0;counter!=(any+1)/2;counter++){
  43.         for(count=spaces;count>0;count--)
  44.             cout<<" ";
  45.         spaces--;
  46.         for(count=size;count>0;count--)
  47.             cout<<"*";
  48.         size+=2;
  49.         cout<<endl;
  50. }
  51. size=any-2;
  52. spaces+=2;
  53. for(counter=any/2;counter>0;counter--){
  54.     for(count=0;count!=spaces;count++)
  55.         cout<<" ";
  56.     spaces++;
  57.     for(count=size;count>0;count--)
  58.         cout<<"*";
  59.     size-=2;
  60.     cout<<endl;
  61.     }
  62.  
  63. system ("PAUSE");
  64.  
  65. }
To start with you can't define a function within a function. Try pulling this outside the main function, that might give you an ide of where the problems with your code are.

Until you really know what you are doing always wrap if statements and for / while loops in '{}' brackets; although you don't need them they make it harder for you to make mistakes and the make it easier for other people to read you code. In your case I'm not really sure where one function is supposed to start and the other end, for example;
Expand|Select|Wrap|Line Numbers
  1. size=any-2;
  2. spaces+=2;
  3. for(counter=any/2;counter>0;counter--){
  4.     for(count=0;count!=spaces;count++)
  5.         cout<<" ";
  6.     spaces++;
  7.     for(count=size;count>0;count--)
  8.         cout<<"*";
  9.     size-=2;
  10.     cout<<endl;
  11.     }
  12.  
  13. system ("PAUSE");
  14.  
  15. }
Isn't part of any function
Mar 17 '08 #2

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

Similar topics

1
by: FS | last post by:
where is it that you are adding the code for the banner to pop up nex to your logo? Ive tried adding the image in the banners section to n avail. Any thoughts http://eye.cc -php- web design
0
by: Ron Lounsbury | last post by:
We have 2 copies of our web application - Development and Checkout. We have noticed that when the QA quys go through our QA version, they will sometimes find that pages are missing the banners. ...
0
by: Andy Dingley | last post by:
http://www.glasgowsurvival.co.uk/weapons/glaWeapons.html I liked this page too: http://www.glasgowsurvival.co.uk/gallery/glaNedGal.html Piccies and piccies of neds (scallies in my local...
1
by: Terry Haufler | last post by:
I am trying to swap/rotate random flash banners using the following Javascript code. I have 3 flash headers/banners. I can get it to open a page with a random header using...
1
by: Jimmy | last post by:
In the asp.net application I develop, we need to provide the marketing department with the ability to insert small JavaScript code snippets into predefined content areas on several pages. This code...
1
by: Jimmy | last post by:
In the web application I develop, we need to provide the marketing department with the ability to insert small JavaScript code snippets into predefined content areas on several pages. This code is...
2
by: Crash44 | last post by:
This is driving me quite nuts. I have created several flash banners for a record label. They are meant to link to an artist splash page. Simple enough, right? Both Mac and PC users can click on...
1
torquehero
by: torquehero | last post by:
Hi.... I am looking for some really good web banners for my Website. I am a designer but havent worked much with websites. So I would really appreciate it if anybody could give me some...
2
by: blaqpig | last post by:
ok not sure how to go about this but what is the best possible way to make a site but also make room for banners. Should each banner (160x600, etc) be put in its own table down the left lets say. ...
3
by: jock1up | last post by:
I am working with javascript...where I have cycling banners at the top, 3 of them and I need to make two of them clickable to a website that I assign to the two. bannerad2 for www.bigmtn.com and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.