Best Graphics Project Live On Management

 #include<stdio.h>

#include<conio.h>
#include<graphics.h>

void insert_record();
void display_record();
void search_record();
void del_record();
void update_record();
void sort_record();
struct student
{
int roll;
char sec[10];
char name[40];
int marks;
float per;
};

struct student s;
void main()
{

	  while(1)
	{
	char ch;
	clrscr();
   textbackground(YELLOW);
   window(1,1,80,25);
	clrscr();
   textcolor(WHITE);
   gotoxy(2,2);
   cprintf(" HARI OM                [00.00.0000] & [00.00]          Developer:-RT LavKush");
   gotoxy(3,6);
   cprintf(" %c CONTACT %c",16,17);
   gotoxy(3,8);
   cprintf("[ RT LAVKUSH ]");
   gotoxy(3,9);
   cprintf("--------------");
   gotoxy(3,10);
   cprintf("%c 6207259544",26);
   gotoxy(3,11);
   cprintf("--------------");
   gotoxy(3,12);
   cprintf("%c 6200994028",26);
   gotoxy(3,13);
   cprintf("--------------");
   gotoxy(3,14);
   cprintf("  YOUTUBE");
   gotoxy(3,15);
   cprintf("    ^");
   gotoxy(3,16);
   cprintf(" HERRY CODE");
   gotoxy(3,17);
   cprintf("--------------");
   gotoxy(3,18);
   cprintf("   Gmail");
   gotoxy(3,19);
   cprintf(" (kush22aur");
   gotoxy(3,20);
   cprintf("@gmail.com)");
   gotoxy(3,21);
   cprintf("--------------");
   gotoxy(3,22);
   cprintf("  WEBSITE");
   gotoxy(3,23);
   cprintf("     ^");
   gotoxy(3,24);
   cprintf("hari4your.blogspot.com");
   textcolor(WHITE);
   gotoxy(67,6);
   cprintf("  %c ABOUT %c",16,17);
   gotoxy(66,8);
   cprintf("  Guide By:-");
   gotoxy(65,9);
   cprintf("   MD Jahangir");
   gotoxy(65,10);
   cprintf("  -------------");
   gotoxy(65,11);
   cprintf("  Co-Developer:-");
   gotoxy(65,12);
   cprintf("   Best Friends");
   gotoxy(67,13);
   cprintf("-------------");
   gotoxy(67,15);
   cprintf("-------------");
   gotoxy(67,17);
   cprintf("-------------");
   gotoxy(67,19);
   cprintf("-------------");
   gotoxy(67,21);
   cprintf("-------------");
   gotoxy(67,22);
   cprintf("For More Info");
   gotoxy(68,23);
   cprintf("    ^");
   gotoxy(57,24);
   cprintf("lavkush106.blogspot.com");

   //clrscr();
	window(18,6,65,23);
  textbackground(BLACK);

  clrscr();
//  gotoxy(15,3);
 //cprintf("------------------");
   textbackground(WHITE);
   textcolor(RED);
   gotoxy(12,3);
   cprintf("        MAIN MENU        ");
   textbackground(BLACK);
   textcolor(WHITE);


	 gotoxy(13,6);
	 cprintf("1 %c JOIN NEW STUDENT",26);
	 gotoxy(13,7);
	 cprintf("2 %c DISPLAY STUDENTS",26);
	 gotoxy(13,8);
	 cprintf("3 %c SEARCH STUDENT",26);
	 gotoxy(13,9);
	 cprintf("4 %c REMOVE STUDENT",26);
	 gotoxy(13,10);
	 cprintf("5 %c UPDATE DETAILS",26);
	 gotoxy(13,11);
	 cprintf("6 %c SHORT DETAILS",26);
	 gotoxy(13,12);
	 cprintf("7 %c LEAVE",26);
	 gotoxy(8,14);
	 printf("---------------------------------");
	 gotoxy(7,15);
	 printf("|                                 |");
	 textcolor(YELLOW);

	 gotoxy(14,15);
	 cprintf("Enter Your Choice ?");
		 gotoxy(8,16);
	 printf("---------------------------------");
		 gotoxy(38,15);

		ch=getche();



	 switch(ch)
	 {
		   case '1':
		clrscr();
			   insert_record();
			   break;
		case '2':
		clrscr();
			display_record();

			break;
		 case '3':
		 clrscr();
			 search_record();
			 break;
		  case '4':
		  clrscr();
			  del_record();
			  break;
		   case '5':
			clrscr();
			   update_record();
			   break;
			case '6': clrscr();
				sort_record();
				break;
			 case '7':
				exit(0);
				break;
			default:
			gotoxy(18,17);
				printf("Try Again !");
				getch();
				break;


		  }

		}


 }
 //*****************FUNCTIONS**************************
//  1
 void insert_record()
 {

	   FILE *fp;
	  fp=fopen("stu.txt","a");
	  if(fp==NULL)
	  {
		printf("\n\t\tError: Cannot Open The File!!!");
		return;

	  }
	  window(1,1,80,25);
	  textbackground(WHITE);
	  clrscr();
	/*   window(1,1,40,25);
	  textbackground(WHITE);
	  clrscr();   */

	  textcolor(BLUE);
	   gotoxy(28,2);
	  cprintf("ENTER NEW STUDENT DETAILS ");
	  gotoxy(15,4);
	  cprintf("Enter Student Roll Number:");
	  scanf("%d",&s.roll);
	  fflush(stdin);
	  gotoxy(15,5);
	  cprintf("Enter Student Name:");
	  scanf("%s",s.name);
	  gotoxy(15,6);
	  cprintf("Enter Student Section:");
	  scanf("%s",s.sec);
	  gotoxy(15,7);
	  cprintf("Enter Student Total Marks:");
	  scanf("%d",&s.marks);
	  gotoxy(15,8);
	  cprintf("Enter Student Percentage:");
	  scanf("%f",&s.per);
	  fwrite(&s,sizeof(s),1,fp);
	  {
	  textcolor(BLACK+BLINK);
		  gotoxy(14,14);
		cprintf("!!!Student Record Inserted Successfully");


		getch();
	  }

	  fclose(fp);

	 }




 // 2
 void display_record()
{
	FILE *fp;
	int i;    //  intialization
	fp=fopen("stu.txt","r");
	if(fp==NULL)
	{
	   printf("Error :Cannot open the file!!!");
	   return;
	}
	window(1,1,80,25);
	textbackground(23);
	clrscr();
	textcolor(22);
	gotoxy(24,2);
	cprintf("  WELCOME TO STUDENT RECORDS");
	gotoxy(24,3);
	cprintf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
	gotoxy(1,5);
	cprintf("      Roll.No      Student Name     Section    Marks     Percentage\n");
	gotoxy(1,6);
	textcolor(YELLOW);
	cprintf("     ---------------------------------------------------------------");
	i=5;                                //extre variable
	while((fread(&s,sizeof(s),1,fp))==1)
	{

	textbackground(BLUE);
	gotoxy(5,i=i+2);    //i increase by sir
	textcolor(WHITE);
	cprintf(" %c   %d          %s          %s        %d      %f ",16,s.roll,s.name,s.sec,s.marks,s.per);
	}
	getch();

	fclose(fp);

}

// 3

void search_record()
{
	 int ro,flag=0;
	 FILE *fp;
	 fp=fopen("stu.txt","r");
	 if(fp==NULL)
	 {
	   window(1,1,80,25);
	 clrscr();
	 printf("\n\t\tError: Cannot open the file\n");
	 return;
	 }
	 textbackground(15);
	 window(1,1,80,25);
	 clrscr();
	 gotoxy(30,4);
	 textcolor(BLUE+BLINK);
	 cprintf("SEARCH BY ROLL NUMBER");
	 gotoxy(8,8);
	 printf("Enter Student Roll No Which You Want To Search:");
	 scanf("%d",&ro);
	 while(fread(&s,sizeof(s),1,fp)>0)
 //	 while(fread(&s,sizeof(s),1,fp)>0 && flag==0)
	 {
	   if(s.roll==ro)
	   {
	   flag=1;
	   clrscr();

	   //textbackground(BLUE);
	   textcolor(BLACK);
	   gotoxy(25,3);
	   printf("THIS RECORD SEARCHED BY YOU");
	   gotoxy(25,4);
	  // textbackground(YELLOW);
	   cprintf("%c--------------------------%c",16,17);

	   gotoxy(2,6);
	   cprintf("Roll.No       Student Name             Section    Marks    Percentage");
	   gotoxy(2,7);
	   cprintf("----------------------------------------------------------------------");
	   gotoxy(2,8);
	   cprintf("\n %d             %s                 %s       %d       %f",s.roll,s.name,s.sec,s.marks,s.per);
	   getch();
	   }
	 }
	 if(flag==0)
	 {
	 gotoxy(24,20);
	 textcolor(RED+BLINK);
	 cprintf("No Such Record Found !!!!");
	 getch();
	 }
fclose(fp);
}
// 4

void del_record()
{


  char name[40];
  unsigned flag=0;
// int ro,flag=0;
  FILE *fp,*ft;
  fp=fopen("stu.txt","r");
 // ft=fopen("temt.txt","w");
 if(fp==NULL)
  {

 window(1,1,80,25);
	 clrscr();

	 gotoxy(17,40);
	 printf("Error: Cannot Open The File!!!");
	 return;
  }
	window(1,1,80,25);
	clrscr();
//("\n\t *** Previous Stores Data ***");
 // display_record();
 gotoxy(29,2);
 textcolor(WHITE+BLINK);
 cprintf(" DELETE BY NAME");
 gotoxy(29,3);
 textcolor(BLUE);
 cprintf("----------------");
 gotoxy(10,8);
  printf("Enter Student Name Which You Want To Delete:");
  scanf("%s",&name);
 // scanf("d",&ro);

  ft=fopen("temp.txt","a");
   while(fread(&s,sizeof(s),1,fp)==1)
  {
	  if(stricmp(name,s.name)!=0)
	 // if(ro==s.roll)
	  {
	  gotoxy(20,14);
	  textcolor(RED+BLINK);
	  cprintf("Record Deleted Successfully");
	  getch();
	 fwrite(&s,sizeof(s),1,ft);

	  }
	 else
	 flag=1;


  }
	if(flag==0)
	{
	 gotoxy(25,18);
	 textcolor(RED+BLINK);
	 cprintf(" Oops! Not Found");
	 getch();
	}

  fclose(fp);
  fclose(ft);
  remove("stu.txt");
  rename("temp.txt","stu.txt");

}

// 5

void update_record()
{
	 int ro,flag=0;
	 FILE *fp;
	 fp=fopen("stu.txt","r");
	 if(fp==NULL)
	 {       window(1,1,80,25);
	  clrscr();
	  printf("\n\t\tError: Cannot Open the File!!!");
	  return;
	 }
	   window(1,1,80,25);
	   textbackground(WHITE);
	 clrscr();
	 gotoxy(25,5);
	 textcolor(BLUE+BLINK);
	 cprintf(" UPDATE BY ROLL NUMBER");
	 gotoxy(25,6);
	 textcolor(RED);
	 cprintf("-----------------------");
	 gotoxy(14,10);
	 textcolor(BLACK);
	 cprintf("Enter Roll Number of Student:");
	 scanf("%d",&ro);

	 while(fread(&s,sizeof(s),1,fp)>0 && flag==0)
	 {
	 if(s.roll==ro)
	 {
	 flag=1;
	   window(1,1,80,25);
	 clrscr();
	 textcolor(BLUE);
	 gotoxy(22,2);
	 cprintf("YOU WANT TO UPDATE THIS RECORD");
	 gotoxy(6,4);
	 textcolor(BLACK);
	 cprintf("    Roll No   Name of Student   Section  Marks  Percentage");
	 gotoxy(4,5);
	 cprintf("      ------------------------------------------------------");
	 gotoxy(4,6);
	 cprintf("        %d          %s             %s       %d    %f",s.roll,s.name,s.sec,s.marks,s.per);
	 gotoxy(22,9);
	 textcolor(RED+BLINK);
	 cprintf(" %c Now Enter The Details %c",16,17);
	 textcolor(BLUE);
	 gotoxy(14,12);
	 cprintf("Enter Roll Number:");
	 scanf("%d",&s.roll);
	 //fflush(stdin);
	 gotoxy(14,14);
	 cprintf("Enter The Name:");
	 scanf("%s",&s.name);
	 gotoxy(14,16);
	 cprintf("Enter The Section:");
	 scanf("%s",&s.sec);
	 gotoxy(14,18);
	 cprintf("Enter The Marks:");
	 scanf("%d",&s.marks);
	 gotoxy(14,20);
	 cprintf("Enter The Percentage:");
	 scanf("%f",&s.per);
	 fseek(fp,-(long)sizeof(s),1);
	 fwrite(&s,sizeof(s),1,fp);
	 gotoxy(12,22);
	 textcolor(BLACK+BLINK);
	 cprintf("Record Updated Successfully");
	 }
	 else
	 {
	 gotoxy(20,20);
	 textcolor(GREEN+BLINK);
	 printf("Enter Correct Roll No!!");
	 }
	 }
	 if(flag==0)
	 {
	  printf("\n\t\tError: Something Went Wrong!!!");
	 }
fclose(fp);
}
// 6

void sort_record()
{
	  struct student temp;
	  struct student arr[50];

	  int i,j,k=0;
	  FILE *fp;
	  fp=fopen("stu.txt","r");
	  if(fp==NULL)
	  {
	window(1,1,80,25);
	  clrscr();
	  printf("\n\t\tError: Cannot Open the File!!!");
	  }
	  i=0;
	  while(fread(&arr[i],sizeof(arr[i]),1,fp)==1)
	  {
	 i++;
	 k++;
	  }
	  for(i=0;i<k;i++)
	  {
	  for(j=0;j<k-i-1;j++)
	  {
		if(arr[j].roll>arr[j+1].roll)
		{
		  temp=arr[j];
		  arr[j]=arr[j+1];
		  arr[j+1]=temp;
		  }
		}
	  }

	  for(i=0;i<k;i++)
	  {
	window(1,1,80,25);
	textbackground(YELLOW);
	clrscr();
	gotoxy(25,2);
	textcolor(WHITE+BLINK);
	cprintf("SHORTED LIST OF RECORD");
	gotoxy(4,4);
	textcolor(BLACK);
	cprintf("Roll No  Student Name    Section     Marks     Percentage");
	gotoxy(4,5);
	cprintf("----------------------------------------------------------");
	gotoxy(4,6);
	cprintf(" %d         %s            %s          %d         %f",arr[i].roll,arr[i].name,arr[i].sec,arr[i].marks,arr[i].per);


	  }

	fclose(fp);
	getch();
	window(1,1,80,60);
	textbackground(YELLOW);
	clrscr();
}

Previous Post Next Post