Tuesday, 9 June 2015

Program that take font and background color and text input from a user and display it in center aligned


Code for Program that take font and background color and text input from a user and display it in center aligned in C++ Programming



 



 



 
#include <iostream.h>

#include <conio.h>

void main()

{

clrscr();

cout<<"\t0 - 7 ARE LIGHT COLORS\n\n";

cout<<"\t0 - 14 ARE DARK COLORS\n\n\n ";

cout<<"\nEnter value of TEXTCOLOR:-";

int tc;

cin>>tc;

cout<<"Enter value of TEXTBACKGROUND:-";

int tb,i;

cin>>tb;

clrscr();

textbackground(tb);

textcolor(tc);

clrscr();

cout<<"|";

for(i=0;i<39;i++)

{

cout<<"--";

}

cout <<"|";

cout<<" ";

for(i=0;i<25;i++)
cout<< "=";

cout<<"Program to display entered value in center";

for(i=0;i<25;i++)
cout<<"=";

cout<<endl;

cout<<"|";

for(i=0;i<39;i++)

{

cout<<"-- ";

}

cout<<"|";

char name[50];

cout<<"\n\nEnter Anything to Align it in Center:-";

cin>>name;

cout<<endl<<endl;

int c=0;

while ( name[c] != '\0' )

c++;

int space = (80 - c)/2;

for(i=1;i<space;i++)

cout<<" ";

cout<<name<<endl;

getch();

}
[/Code]

No comments:

Post a Comment