Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- struct Person {
- char name[20];
- int id;
- float money;
- };
- void personInfo(struct Person employee) {
- printf("Name: %s\n", employee.name);
- printf("ID: %d\n", employee.id);
- printf("Money: %lf\n", employee.money);
- printf("\n");
- }
- int main() {
- struct Person employee[3], student[4];
- strcpy(employee[0].name, "Ashik");
- employee[0].id = 1;
- employee[0].money = 450.50;
- strcpy(employee[1].name, "XYZ");
- employee[1].id = 2;
- employee[1].money = 560.08;
- strcpy(employee[2].name, "ABC");
- employee[2].id = 3;
- employee[2].money = 430.44;
- strcpy(student[0].name, "S1");
- student[0].id = 1;
- student[0].money = 450.50;
- strcpy(student[1].name, "S2");
- student[1].id = 2;
- student[1].money = 560.08;
- strcpy(student[2].name, "S3");
- student[2].id = 3;
- student[2].money = 430.44;
- strcpy(student[3].name, "S4");
- student[3].id = 4;
- student[3].money = 430.44;
- printf("Employee Type:\n");
- for (int i = 0; i < 3; i++) {
- personInfo(employee[i]);
- }
- printf("Student Type:\n");
- for (int i = 0; i < 4; i++) {
- personInfo(student[i]);
- }
- }
- // void swap(int *p, int *q) { // Call by Reference
- // int temp = *p;
- // *p = *q;
- // *q = temp;
- // }
- // void swap(int p, int q) { // Call by value
- // int temp = p;
- // p = q;
- // q = temp;
- // printf("Inside Function: %d %d\n", p, q);
- // }
- // int main() {
- // int a, b;
- // scanf("%d %d", &a, &b);
- // printf("Before change: %d %d\n", a, b);
- // swap(&a, &b); // Call by Reference
- // printf("After change: %d %d\n", a, b);
- // }
- // int main() {
- // int a, b;
- // scanf("%d %d", &a, &b);
- // int *p;
- // p = &a;
- // printf("Before Change: %d\n", *p);
- // p = &b;
- // printf("After Change: %d\n", *p);
- // }
- // int func(int x) {
- // if(x % 2 == 0) {
- // return 1;
- // } else {
- // return 0;
- // }
- // }
- // int main() {
- // int n; // Local variable
- // scanf("%d", &n);
- // int ans = func(n);
- // if(ans) {
- // printf("Even\n");
- // } else {
- // printf("Odd\n");
- // }
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement