Formatted Report Printer:
C
Medium
3 views
Problem Description
By printing student data (name, roll no, marks) in table format where columns are properly aligned. Names should be left-aligned, numbers right-aligned, and proper spacing maintained.
Official Solution
#include <stdio.h>
int main() {
char name[3][20] = {"Alice", "Bob", "Christopher"};
int roll[3] = {101, 12, 7};
float marks[3] = {89.5, 76.25, 92.0};
int i;
printf("n%-20s %10s %10sn", "Name", "Roll No", "Marks");
printf("----------------------------------------------n");
for (i = 0; i < 3; i++) {
printf("%-20s %10d %10.2fn", name[i], roll[i], marks[i]);
}
return 0;
}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!