472,804 Members | 1,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,804 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 6803
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.