Bubble Sort in C
Bubble Sort Here, You will learn Bubble sort Algorithm and get the program code of Bubble Sort in C programming. Bubble sort is a sorting algorithm concept from the Data […]
Bubble Sort Here, You will learn Bubble sort Algorithm and get the program code of Bubble Sort in C programming. Bubble sort is a sorting algorithm concept from the Data […]
Find Roots of Quadratic Equation Here, you will know about the roots of quadratic equation ,and get the example code of c program to find roots of quadratic equation using
Simple Calculator program in C Here, you will get a simple calculator program in c programming language. This program will perform basic mathematical operations like addition, subtraction, multiplication, and division
Find Odd or Even Program in C Here, you will get an example code to find odd or even program in c programming. First, we will take a number as
getchar and putchar in C Here, you will get a program code to use the predefined functions getchar and putchar in C programming. In this program we will reads a
Payroll Data Entry using file handling in c Here you will get a source code of Payroll Data Entry using File handling in C example with c language. File Handling
Employee Record System in C Here you will get the program code of Employee Record System in C using File Handling. Employee Record System in C using File Handling
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | #include<stdlib.h> #include<conio.h> #include<stdio.h> #include<string.h> main() { FILE *fp,*ft; char another,choice; struct emp { char name[40]; int age; float bs; }; struct emp e; char empname[40]; long int recsize; clrscr(); fp=fopen("EMP.DAT","rb+"); if ( fp== NULL) { fp= fopen("EMP.DAT ","wb+"); if (fp==NULL) { puts("\nCannot open file"); exit(1); } } recsize= sizeof(e); while(1) { gotoxy(10,10); printf("1. Add Records"); gotoxy(10,12); printf("2. Display Records"); gotoxy(10,14); printf("3. Modify Records"); gotoxy(10,16); printf("4. Delete Records"); gotoxy(10,18); printf(" 0. Exit"); gotoxy(10,20); printf("Your choice"); fflush(stdin); choice=getche(); switch(choice) { case'1': clrscr(); fseek(fp,0,SEEK_END); another='Y'; while(another=='Y') { printf("\n Enter name, age and basic sal"); scanf("%s%d%f",e.name,&e.age,&e.bs); fwrite(&e,recsize,1,fp); printf("\n Add another record(Y/N)"); fflush(stdin); another= getche(); } break; case'2': clrscr(); rewind(fp); while( fread(&e,recsize,1,fp)==1) printf("\n%s %d %f",e.name,e.age,e.bs); break; case'3': clrscr(); another='Y'; while(another=='Y') { printf("\n Enter name of employee to modify"); scanf("%s",empname); rewind(fp); while(fread(&e,recsize,1,fp)==1) { if (strcmp(e.name,empname)==0) { printf("\n Enter new name , age & bs"); scanf("%s%d%f",e.name,&e.age,&e.bs); fseek(fp,recsize,SEEK_CUR); fwrite(&e,recsize,1,fp); break; } } printf("\nModify another record(Y/N)"); fflush(stdin); another=getche(); } break; case'4': clrscr(); another='Y'; while( another=='Y') { printf("\n Enter name of employeeto delete"); scanf("%s", empname); ft=fopen("TEMP.DAT","wb"); rewind(fp); while(fread(&e,recsize,1,fp)==1) { if (strcmp(e.name,empname)!=0) fwrite(&e,recsize,1,ft); } fclose(fp); fclose(ft); remove("TEMP.DAT"); rename("TEMP.DAT","EMP.DAT"); fp=fopen("EMP.DAT","rb+"); printf("\nDo you want to Delete another record(Y/N)"); fflush(stdin); another=getche(); } break; case'0': fclose(fp); exit(1); } } } |
Floyds Triangle in C In this program, you will get and learn the program code of floyds triangle in c programming. Floyd’s triangle is a triangular shaped, array of natural
Calculator Program in C Here you get the example code of Calculator Program in C using Switch Case. Calculator definition: An electronics machine, that is used to do the arithmetical