Showing posts with label PROGRAMMING. Show all posts
Showing posts with label PROGRAMMING. Show all posts

Student Record-File Management Program in C

c-techaravind-student-record-img
                                              To compile and execute the program, copy the code into a text file. Save the text file with the extinction .c (ex. program.c). Save your file in turboc2 or borland (it may your othe c-compiler). Now open you IDE (tc.exe) , goto file->pick file. Your source file will be loaded into IDE. Now you can compile and run the file easily.

C program for append,list,search ,modify,delete a student record in a File.


#include<stdio.h>
#include<conio.h>
void append();
void list();
void search();
void modify();
void del();

struct student
{
int no;
char name[20];
};

void main()
{
int a;
char ch;
clrscr();
do{
printf("\nstudent DATABASE\n\n");
printf("1.Append student Record\n2.List student Record\n3.Modify student Record\n4.Delete student Record\n5.Search student Record\n Enter Choice : ");
scanf("%d",&a);
switch(a)
{
case 1:
append();
break;
case 2:
list();
break;
case 3:
modify();
break;
case 4:
del();
break;
case 5:
search();
break;
default :
printf("Invalid Choice!");
}
printf("\n More Actions ? (Y/N) :");
fflush(stdin);
scanf("%c", &ch);
}while(ch=='y'|| ch=='Y');
}

void append()
{
int i,n;
struct student e;
FILE *fp;
fp=fopen("student.dat", "a");
if(fp==NULL)
{
printf("File Creation Failed!");
exit(0);
}
printf("Enter the nos. of students : ");
scanf("%d", &n);
for(i=0;i<n;i++)
{
printf("Enter the student Number : ");
scanf("%d", &e.no);
printf("Enter the student Name : ");
fflush(stdin);
gets(e.name);
printf("\n\n");
fwrite((char *)&e, sizeof(e), 1, fp);
}
fclose(fp);
}

void list()
{
int nofrec=0;
struct student e;
FILE *fp;
fp=fopen("student.dat", "rb");
if(fp==NULL)
{
printf("\n\tFile doesn’t exist!!!\TRY AGAIN");
exit(0);
}
while((fread((char *)&e, sizeof(e), 1, fp))==1)
{
nofrec++;
printf("\nstudent Number : %d", e.no);
printf("\nstudent Name : %s",e.name);
printf("\n\n");
}
printf("Total number of records present are : %d", nofrec);
fclose(fp);
}

void modify()
{
int recno, nofrec=0;
char ch;
struct student e;
FILE *fp;
fp=fopen("student.dat", "rb+");
printf("Enter the student Number to modify : ");
scanf("%d", &recno);
while((fread((char *)&e, sizeof(e), 1, fp))==1)
{
nofrec++;
if(e.no==recno)
{
printf("\nstudent Number : %d", e.no);
printf("\nstudent Name : %s",e.name);
printf("\n");
printf("Do you want to modify this record : ? (Y/N)");
fflush(stdin);
scanf("%c", &ch);
fseek(fp, ((nofrec-1)*sizeof(e)), 0);
if(ch=='Y'|| ch=='y')
{
printf("Enter the student No : ");
scanf("%d",&e.no);
printf("Enter the student Name : ");
fflush(stdin);
gets(e.name);
fwrite((char *)&e, sizeof(e), 1, fp);
printf("Record Modified");
}
else
printf("No modifications were made");
fclose(fp);
}
}
}
void del()
{
int recno;
char ch;
struct student e;
FILE *fp, *ft;
fp=fopen("student.dat", "rb");
ft=fopen("Temp.dat", "wb");
printf("Enter the student Number to delete : ");
scanf("%d", &recno);
while((fread((char *)&e, sizeof(e), 1, fp))==1)
{
if(e.no==recno)
{
printf("\nstudent Number : %d", e.no);
printf("\nstudent Name : %s",e.name);
printf("\n");
printf("Do you want to delete this record : ? (Y/N)");
fflush(stdin);
scanf("%c", &ch);
}
}
if(ch=='y'||ch=='Y')
{
rewind(fp);
while((fread((char *)&e, sizeof(e), 1, fp))==1)
{
if(recno!=e.no)
{
fwrite((char *)&e, sizeof(e), 1, ft);
}
}
}
else
printf("No Record was deleted");
fclose(fp);
fclose(ft);
remove("student.dat");
rename("Temp.dat", "student.dat");
}


void search()
{
int s,recno;
char sname[20];
struct student e;
FILE *fp;
fp=fopen("student.dat", "rb");
printf("\n1.Search by Name\n2.Search by student No.\n Enter choice : ");
scanf("%d", &s);
switch(s)
{
case 1:
printf("Enter the student Name to Search : ");
fflush(stdin);
gets(sname);
while((fread((char *)&e, sizeof(e), 1, fp))==1)
{
if(strcmp(sname,e.name)==0)
{
printf("\nstudent Number : %d", e.no);
printf("\nstudent Name : %s",e.name);
printf("\n");
}
}
break;
case 2:
printf("Enter the student Number to Search : ");
scanf("%d", &recno);
while((fread((char *)&e, sizeof(e), 1, fp))==1)
{
if(e.no==recno)
{
printf("\nstudent Number : %d", e.no);
printf("\nstudent Name : %s",e.name);
printf("\n");
}
}
break;
}
}




Future Of Java



img




Computer's modern history is changed forever when it was introduced in 1995, Sun Java Micro systems in the world of James Gosling. Since then he returned and the most popular Java programming language was preferred by programmers around the world. To the various types of software and other Web applications are designed. 





Like most programming languages, it is constantly changing language in the last fifteen years has been tweaked a lot smoother, and improve efficiency. Although Java has different goals easy PHP, which is published in the same year can be compared. However, innovative website design is used for PHP, the Java, which is freely available to the general public as an open source language. 





Java programming language has many advantages, but more the fact that the Java virtual world is easy to understand for novice programmers is a dream come true may be more important. Writing Java development work can be described as polite, easy to create software applications critical to a user's computer, find your way in life improved. 





Refer to another point that Java is used on any platform without the intervention. Whether Windows or Linux, Java, you will give the same answer regardless of the operating system. All languages ??can claim such a novelty. 





In that time, a Pandora's box is opened wiki leaks, Java programming language as a priority to maintain the security has been put in place. When work in a safe environment for Java, so the virus can not attack the host system is used. 





Overview of Java is different from other languages. Not only is it reliable (the disappearance of a large number of initial errors made later), but it also supports multi-threaded programming, applications to software developers to help with many levels. Java language as a whole is very advanced: the units of code sections, which are present in a Java interpreter, known only economic, as expressed in necessary. The bottom line of the avant-grade language of its versatility, simplicity and total running without error. Since its inception, the Java web world in a variety of areas have a variety of software used. These languages ??have been huge leaps and trumpeter Java than many experts. 





Clearly, however, Java has come up, the simple reason that you can do with these languages ??to write. Spectrum and may explain the Java code in front of the tongue breathtaking potential for maturity is bright red.

 
Etutos © 2010-2011