i have a simple asterisk graph program but i am having trouble anout the output how will i align the result of the other perosn..
this is my code

#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <string>
#include <windows.h>
#include <iomanip>
using namespace std;

void main()
{
	  int cartoon;
	  int voters;
	  int spongebob=0;
	  int dora=0;
	  int y;//loop
	  char x='*';
	  int t;//total

	 

	  cout<<endl;
	  cout<<setw(60)<<"Survey for you Favorite Cartoon Character"<<endl;
	  cout<<endl;
	  cout<<endl;
	  cout<<setw(35)<<"PRESS 1"<<setw(5)<<"for"<<setw(10)<<"SPONGEBOB"<<endl;
	  cout<<setw(35)<<"PRESS 2"<<setw(5)<<"for"<<setw(5)<<"DORA"<<endl;
	  cout<<endl;
	  cout<<endl;
	  cout<<setw(20)<<"Enter the number of voters:";
	  cin>>voters;

	  for(y=1;y<=voters;y++)
	  {
		  cout<<"Survey for your favorite Cartoon Character:";
		  cin>>cartoon;

		  if(cartoon==1)
		  {
			  spongebob=spongebob+1;
		  }
		  else if (cartoon==2)
		  
			  dora=dora+1;
		  }
		  cout<<endl;
		  cout<<endl;

		  cout<<setw(45)<<"Total votes:"<<endl;  
		  cout<<endl;
		  cout<<endl;
		  x=spongebob/1;
		  cout<<setw(30)<<"SPONGEBOB:"<<spongebob<<setw(20)<<"DORA:"<<dora<<endl;
		  for(t=1;t<=x;t++)
		  {
			  cout<<setw(25)<<'*';
			  cout<<endl;
		  }
		   
		  x=dora/1;
	
		  for(t=1;t<=x;t++)
		  {
			  cout<<'*';
			  cout<<endl;
		  }
		  getch();
	  }

when i run the program the result of dora is not align pls help

this is the result whe the output comes

spongebob

When it comes to alignment, just play with the different setw() values until you get what you want. Alternatively, you could show the votes horizontally instead of vertically. That simplifies a lot of things.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.