menu search
brightness_auto
more_vert
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
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

1 Answer

more_vert
 
verified
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

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
What does the question actually mean?

Related questions

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
0 answers
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 1 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 1 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
1 answer

4.8k questions

4.3k answers

67 comments

388 users

...