0 votes
2.0k views
in Programming by (98.9k points)
reopened by
Write a C++ program that right justifies text. It should read and echo a sequence of left justified lines and print them in right justified format.

[March 2003, March 2006, Oct. 2006, Oct. 2003, March 2005, March 2007] Computer science program maharashtra board

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer

#include<iostream.h>
#include<conio.h>
#include<string.h>

void main()
{
char line[5][100];
int i, j, len, maxlen=0;
for(i=0; i<=4; i++)
{
cin.getline(line[i], 99, '\n');
len=strlen(line[i]);
if(len>maxlen)
maxlen=len;
}
for(i=0; i<=4; i++)
{
len=strlen(line[i]);
for(j=1; j<=maxlen-len; j++)
{
cout<<" ";
}
cout<<line[i]<<endl;
}
}

Only works in Turbo c++ for maharashtra board syllabus

asked Mar 21, 2022 in Programming by anonymous
edited Jun 29, 2023
What does the question actually mean?

Related questions

0 votes
0 answers 152 views
0 votes
1 answer 419 views
0 votes
1 answer 355 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

557 users

...