[Legacy Content] This page contains very old information, which might not be valid anymore, they are only kept here for legacy purposes.
if you have any inquiries, feel free to contact me! Click here
Created: Monday, 12 August 2013 Written by Ehab Eldeeb
#include <stdio.h>
#include <conio.h>// Structs MUST BE defined before main() .. Use this stock every time, just change the name for the struct, and what's inside it for sure..
typedef struct { // always write it like that
int ID; // a variable with type int in the struct
float GPA; // a variable with type float in the struct
char name[20]; // a string in the struct
} student; // struct name
int main(){
student X; // define a new struct with variable name X (just like when you define an int variable int x; )// to read name of student
printf("Enter name of student: ");
gets(X.name); // gets to read string right? .. what's inside is like .. name inside the struct x.. just like a name in a box// to read student's ID
printf("Enter student ID: ");
scanf("%d", &X.ID); // scanf 3ady gedan bas hate2ra ID gowa struct X// to read student's GPA nafs el kalam
printf("Enter student GPA: ");
scanf("%f", &X.GPA); // e2ra el GPA gowa el struct Xgetch();
return 0;
}