Write a program to demonstrate the use of star for formatting.

formating
#include<stdio.h>
#include<conio.h>
int main()
{
	int x=55,y=33;
	printf("\n %*d",15,x-y);
	printf("\n %*d",5,x-y);
	getch();
}



/*The value is given along the set of variables.You can observe in the printf() statements the value
15 and 5 that indicate the position from where printing on screen begins.*/

This program demonstrates the use of the * character in the printf function for formatting output. The * character can be used to specify a field width for the output value. In the first printf statement, 15 is used as the field width, meaning that the output value should be right-aligned within a field of width 15 characters. In the second printf statement, 5 is used as the field width, meaning that the output value should be right-aligned within a field of width 5 characters. The actual output value in both cases is 22, which is calculated as x-y.

Thanks

Write a program to demonstrate the use of star for formatting.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top