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...
C Program: (Knapsack Exhaustive): How do I add the 5 random generated values into the val...
C Program: (Knapsack Exhaustive): How do I add the 5 random generated values into the val [] arrays and how to add the total maximum weights ?    // returns maximum of two integers    int max(int a, int b) { return (a > b)? a : b; }       // Returns the maximum value that can be put in a knapsack of capacity W    int knapSackExhaustive(int W, int wt[], int val[], int n){    if (n ==...
(Python) How would I add this input into my code? "Enter Y for Yes or N...
(Python) How would I add this input into my code? "Enter Y for Yes or N for No:" as a loop. def getMat(): mat = np.zeros((3, 3)) print("Enter your first 3 by 3 matrix:") for row in range(3): li = [int(x) for x in input().split()] mat[row,0] = li[0] mat[row,1] = li[1] mat[row,2] = li[2] print("Your first 3 by 3 matrix is :") for i in range(3): for k in range(3): print(str(int(mat[i][k]))+" ",end="") print() return mat def checkEntry(inputValue): try: float(inputValue) except...
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 do I source for academic references for my assignments
how do I source for academic references for my assignments
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT