Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (anonymous):

Hi, there. I need a program in C++ that left indents the text we enter, on the monitor. We have to just write it in basic procedure oriented approach. PS: I am new to programming.

OpenStudy (anonymous):

One option would be to just print some spaces using printf(" ");

OpenStudy (anonymous):

Or use the \t escape code to instert tabs :) printf("This is not indented"); printf("\tThis is");

OpenStudy (anonymous):

Well I actually made a mistake in my question and I apologize for it. We need to right indent the text that we enter. Also the main thing to be considered is that it should be at exactly the end of the screen on the right side.

OpenStudy (anonymous):

Try this code the first two print statements output the text at the right of the screen as long as you are using a standard 80 character screen. The last one indented from the right the length of the text, just for fun. #include <stdio.h> #include <string.h> int main(void) { int SCREEN_SIZE = 80; char* s1 = "Some test text"; char* s2 = "Some more test text"; printf("%80s\n","test"); printf("%*s\n",SCREEN_SIZE,s1); printf("%*s\n",SCREEN_SIZE-strlen(s2),s2); }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!