|
125 | 125 | // }
|
126 | 126 |
|
127 | 127 | // 🛑 Passing structure to function | Call by Reference 🌟 🌟 |
|
| 128 | +// #include <stdio.h> |
| 129 | +// // user Difined |
| 130 | +// struct student { |
| 131 | +// char name [32]; |
| 132 | +// int roll; |
| 133 | +// float cgpa; |
| 134 | +// }; |
| 135 | +// void printInfo(struct student s1); |
| 136 | +// int main(){ |
| 137 | +// struct student s1 = {"Programmer" , 302 , 3.4}; |
| 138 | +// printInfo(s1); // Function call |
| 139 | + |
| 140 | + |
| 141 | +// s1.roll = 303; |
| 142 | +// printf("Student roll ; %d\n" , s1.roll); |
| 143 | +// return 0; |
| 144 | +// } |
| 145 | +// // Function Definition |
| 146 | +// void printInfo(struct student s1){ |
| 147 | +// printf("print Information : "); |
| 148 | +// printf("Student Name is : %s\n" , s1.name); |
| 149 | +// printf("Student roll ; %d\n" , s1.roll); |
| 150 | +// printf("Student cgpa : %f\n" , s1.cgpa); |
| 151 | +// s1.roll = 303; |
| 152 | +// } |
| 153 | + |
| 154 | +// Typedef Keyword |
| 155 | + |
128 | 156 | #include <stdio.h>
|
129 |
| -// user Difined |
130 |
| -struct student { |
131 |
| -char name [32]; |
| 157 | +#include <string.h> |
| 158 | +typedef struct CoumputerSceinceEngineearing{ |
| 159 | +char name [22]; |
132 | 160 | int roll;
|
133 | 161 | float cgpa;
|
134 |
| -}; |
135 |
| -void printInfo(struct student s1); |
| 162 | +}CSE; |
136 | 163 | int main(){
|
137 |
| - struct student s1 = {"Programmer" , 302 , 3.4}; |
138 |
| - printInfo(s1); // Function call |
139 |
| - |
| 164 | + CSE s1; |
| 165 | + strcpy(s1.name,"Developer"); |
| 166 | + s1.roll = 604; |
| 167 | + s1.cgpa = 2.6; |
| 168 | + printf("Student name is : %s\n" , s1.name); |
| 169 | + printf("Student roll : %d\n" , s1.roll); |
| 170 | + printf("Student cgpa : %f\n" , s1.cgpa); |
140 | 171 |
|
141 |
| - s1.roll = 303; |
142 |
| - printf("Student roll ; %d\n" , s1.roll); |
143 | 172 | return 0;
|
144 | 173 | }
|
145 |
| -// Function Definition |
146 |
| -void printInfo(struct student s1){ |
147 |
| -printf("print Information : "); |
148 |
| -printf("Student Name is : %s\n" , s1.name); |
149 |
| -printf("Student roll ; %d\n" , s1.roll); |
150 |
| -printf("Student cgpa : %f\n" , s1.cgpa); |
151 |
| -s1.roll = 303; |
152 |
| -} |
| 174 | + |
153 | 175 |
|
154 | 176 | // #include <stdio.h>
|
155 | 177 | // int main(){
|
|
0 commit comments