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
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...
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? The history of eugenics can be dated back to the 19th c (Wilson,2019). Eugenics is a practice that aids in filtering out good and bad genes in one's genetic makeup. Ideally, for some, this practice would focus primarily on ruling out disease processes rather than for aesthetics. However, sometimes in eugenics, it also includes the concept of trying to create...
What element they are: 1.My appearance at standard state is a silvery-white. My density when I...
What element they are: 1.My appearance at standard state is a silvery-white. My density when I melt is 1.46g/cm3. I burn purple, and react violently on contact with water. I see use in atomic clocks, and sometimes in glass 2.I am a diatomic molecule with a melting point of -259.14˚C and have a lower density than any other element.I am highly flammable and commonly form compounds with non-metals and halogens.I am commonly found in a product used to clean wounds...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT