Question

In: Computer Science

How do I add white space in the beginning of my printf statement in C? I...

How do I add white space in the beginning of my printf statement in C? I also need the white space to be dynamic by using an int value as reference for the amount of spaces. Thanks!

Solutions

Expert Solution

Code with example

#include<stdio.h>

int main()

{

int indent;

char *string ="My name is jay";

printf("How many space you neede: ");

scanf("%d",&indent);

printf("%*s%s ", indent, "", string);

return 0;

}

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.


Related Solutions

How do I add the information below to my current code that I have also posted...
How do I add the information below to my current code that I have also posted below. <!DOCTYPE html> <html> <!-- The author of this code is: Ikeem Mays --> <body> <header> <h1> My Grocery Site </h1> </header> <article> This is web content about a grocery store that might be in any town. The store stocks fresh produce, as well as essential grocery items. Below are category lists of products you can find in the grocery store. </article> <div class...
How do I add an output operator to a class in C++? The specific part of...
How do I add an output operator to a class in C++? The specific part of the task said to: Define a ​class t​o hold accounts. Use the ​same​ stream variable! Write getters to access the fields in the accounts when printing. Add an output operator for your class. First, Repeat the print loop using this output operator.Now​ make the output operator a friend, by adding a friend​prototype​ to your account class definition. Add a line in the output operator...
How do I add additional command line arguments in C++? I am working on a programming...
How do I add additional command line arguments in C++? I am working on a programming assignment that has the user input a file into the command line and then they have the option to also add a series of other arguments to the command line. I know how to accept the text file from the command line by using: int main(int argc, char *argv[]) { /.../ } Then filename(argv[1]) would be the text file that they put into the...
JAVA: How do I fix the last "if" statement in my code so that outputs the...
JAVA: How do I fix the last "if" statement in my code so that outputs the SECOND HIGHEST/MAXIMUM GPA out of the given classes? public class app { private static Object minStudent; private static Object maxStudent; public static void main(String args[ ]) { student st1 = new student("Rebecca", "Collins", 22, 3.3); student st2 = new student("Alex", "White", 19, 2.8); student st3 = new student("Jordan", "Anderson", 22, 3.1); student[] studentArray; studentArray = new student[3]; studentArray[0] = st1; studentArray[1] = st2; studentArray[2]...
Python I want to name my hero and my alien in my code how do I...
Python I want to name my hero and my alien in my code how do I do that: Keep in mind I don't want to change my code except to give the hero and alien a name import random class Hero:     def __init__(self,ammo,health):         self.ammo=ammo         self.health=health     def blast(self):         print("The Hero blasts an Alien!")         if self.ammo>0:             self.ammo-=1             return True         else:             print("Oh no! Hero is out of ammo.")             return False     def...
how do I copy my word data to excel I typed my report on word document...
how do I copy my word data to excel I typed my report on word document and would like to copy them on excel 2013 in other to add table and graph
I used this code for my first draft assignment. My teacher told me not to add...
I used this code for my first draft assignment. My teacher told me not to add a decrypt function. I have the variable encryptionKey holding 16. I can simply negate encryptionKey with the - in front. Then I make one key change and all the code still works properly. How do I adjust this code? import csv import sys #The password list - We start with it populated for testing purposes passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]] #The password file name to store...
How do I change my if statements into while and for loops, so that I can...
How do I change my if statements into while and for loops, so that I can make my bot go straight and turn exactly 12 times. /*********************************************************************** * Exp7_1_RotaryEncoder -- RedBot Experiment 7_1 * * Knowing where your robot is can be very important. The RedBot supports * the use of an encoder to track the number of revolutions each wheels has * made, so you can tell not only how far each wheel has traveled but how * fast...
How would I add an automatic please fill out this info to my complete code. Something...
How would I add an automatic please fill out this info to my complete code. Something similar to this code. <!doctype html> <html> <head> <meta charset="UTF-8"> <title>Untitled Document</title> <script>    function phonenumber(inputtxt){           var phoneno = (\(\d{3}\)|\d{3})[-\s]\d{3}-\d{4};       if(inputtxt.value.match(phoneno)){        document.getElementById("yourEntry").innerHTML = document.getElementById("myphone").value;    }    //if(!inputtxt.value.match(phoneno)){        // alert("Does not Work!")        //}    } </script> </head> <body> <form name="form1" action="#"> <input type="text" name="myphone" id="myphone" value="" pattern= "(\(\d{3}\)|\d{3})[-\s]\d{3}-\d{4}" placeholder="(555) 555-1212" required /> <input...
I need a response for the statement below. Anything to add to the statement, corrections or...
I need a response for the statement below. Anything to add to the statement, corrections or questions about the statement? Eugenics, broken down, means good genes (Pence, 2017). There are positive and negative eugenics. Some contemporary developments in eugenics is “designer babies.” A designer baby is a baby whose genetic makeup has been designed prior to its birth to ensure desired characteristics or to prevent undesired ones (Pence, 2017). This reminds me of people wanting to have Olympic athletes as...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT