Tuesday, February 9, 2016

printf function with formatting.

#include<stdio.h>
int main()
{
float pen, pencil;

printf("Enter your Pen Price:");
scanf("%f", &pen);
printf("Enter your Pencil Price:");
scanf("%f", &pencil);

printf("======= List of Items=========\n");
printf("Item Name\tPrice\n");
printf("Pen\t\tRs. %10.2f\n" , pen);
printf("Pencil\t\tRs. %10.2f\n" , pencil);
printf("======= List of Items=========");
 return 0;
}

Output of program

Enter your Pen Price:10.50
Enter your Pencil Price:5.50
======= List of Items=========
Item Name       Price
Pen             Rs.      10.50
Pencil          Rs.       5.50
======= List of Items=========


No comments:

Post a Comment