១៤៧. បញ្ចូល និងបង្ហាញពត័មានសិស្សលើscreen (struct)¶
លំហាត់ទី១៤៧¶
សរសេកម្មវិធី ដោយប្រើប្រាស់strct បញ្ចូលពត័មានសិស្សម្នាក់(name, roll, marks) រួចបង្ហាញលើ screen។
Source¶
// Stroe information and display of a student using structure
/**
* This program stores the information (name, roll and marks) of
* a student and display it on the screen using structure
*
*/
#include <stdio.h>
struct Student{
char name[50];
int roll;
float marks;
};
int main(int argc, char const *argv[])
{
struct Student s;
printf("Enter information:\n");
printf("Enter name: ");
scanf("%s", s.name);
printf("Enter roll number: ");
scanf("%d", &s.roll);
printf("Enter marks: ");
scanf("%f", &s.marks);
printf("\n\nDisplaying information:\n");
printf("Name: ");
puts(s.name);
printf("Roll number: %d\n", s.roll);
printf("Marks: %.1f\n", s.marks);
return 0;
}
Output¶
Enter information:
Enter name: Channith
Enter roll number: 1001
Enter marks: 9.5
Displaying information:
Name: Channith
Roll number: 1001
Marks: 9.5