Write a C program that creates a little table with three made up people displaye
ID: 665532 • Letter: W
Question
Write a C program that creates a little table with three made up people displayed on the screen.
Your table should be formatted as 5 columns:
1) First and Last Name as a string left justified in 20 spaces
2) Age right justified as an integer in 5 spaces
3) Salary right justified as a floating point number showing 3 decimal places and a dollar sign in front in 15 spaces.
4) Phone Number as a string right justified in 15 spaces.
5) A single character call code as a character followed by a new line. Give the first person the call code J, the second M and the last J.
Explanation / Answer
working c code
#include<stdio.h>
#include<string.h>
int main()
{
char fname[20];
char lname[20];
int age;
float salary;
char pnumber[15];
char code;
scanf("%s ",&fname);
scanf("%s ",&lname);
scanf("%d ",&age);
scanf("%f ",&salary);
scanf("%s ",&pnumber);
scanf("%c ",&code);
printf("Details of the person entered are ");
printf("%s ",fname);
printf("%s ",lname);
printf("%d ",age);
printf("$%f ",salary);
printf("%s ",pnumber);
printf("%c ",code);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.