Pages

Sunday, September 30, 2018

Main Menu Demo Project


Main Menu Demo Project 

  • This project will demonstrate how to create and use Main Menu in project.
  • Project uses concepts of Functions to implement project.

Following Program Demonstrate how to use MAIN MENU in C Project based on Library Management System.

#include<stdio.h>

void MainMenu();
void DrawLine(int n);
void AddBooks();
void AddStudentRecords();
void SearchBooks();
void IssueBooks();
void DisplayBooks();
void EditBooks();

int main(){

MainMenu();

return 0;
} //End of Main function

void MainMenu(){
int choice;
char chr;
system("cls");
DrawLine(15);
printf(" MAIN MENU ");
DrawLine(15);
printf("\n\t1. Add Books\n");
printf("\t2. Add Student Record\n");
printf("\t3. Search Books\n");
printf("\t4. Issue Books\n");
printf("\t5. Display Books\n");
printf("\t6. Edit Book Records\n");
printf("\t7. Exit System\n");
DrawLine(41);

printf("\nEnter your choice:");
scanf("%d", &choice);

switch(choice){
case 1:
AddBooks();
break;
case 2:
AddStudentRecords();
break;
case 3:
SearchBooks();
break;
case 4:
IssueBooks();
break;
case 5:
DisplayBooks();
break;
case 6:
EditBooks();
break;
case 7:
printf("Exiting System...\n");
printf("\nAre you sure!!!\nPress Y/y to Exit and N/n to Continue..");
chr = getch();
if(chr == 'Y' || chr == 'y')
printf("\nHave a Nice Day..");
else
MainMenu();
break;
default: printf("Invalid Input...Try again...");
break;
}
}//End of MainMenu
void DrawLine(int n){
int i;
for(i=0; i<n; i++)
printf("%c",254);
}
void AddBooks(){
system("cls");
DrawLine(30);
printf("\nAdd Logic of Add Books here...\n");
DrawLine(30);
getch();
MainMenu();
}

void AddStudentRecords(){
system("cls");
DrawLine(30);
printf("\nAdd Logic of Student Record here...\n");
DrawLine(30);
getch();
MainMenu();
}

void SearchBooks(){
system("cls");
DrawLine(30);
printf("\nAdd Logic of Search Books here...\n");
DrawLine(30);
getch();
MainMenu();
}

void IssueBooks(){
system("cls");
DrawLine(30);
printf("\nAdd Logic of Issue Books here...\n");
DrawLine(30);
getch();
MainMenu();
}

void DisplayBooks(){
system("cls");
DrawLine(30);
printf("\nAdd Logic of Display Books here...\n");
DrawLine(30);
getch();
MainMenu();
}

void EditBooks(){
system("cls");
DrawLine(30);
printf("\nAdd Logic of Edit Books here...\n");
DrawLine(30);
getch();
MainMenu();
}
//This code is developed by CProgramPracticals.Blogspot.Com
//Give reference to CProgramPracticals.Blogspot.Com site while using this code.

Sample Output
Library Management System - Sample Main Menu C Project
Fig. Sample Output for Project Library Management System - Main Menu Code



Saturday, September 22, 2018

Count vowels in given file.


C Program to count Vowels in a given file.

This program will read input from "data.txt" file and prints total number of vowels.

#include<stdio.h>
int main()
{
  FILE *fp;
  char ch;
  int cnt=0;

  fp = fopen("data.txt","r");

  if (fp == NULL)
  {
  printf("Can't Open File.");
  exit(1);
  }
  printf("File content is : ");
  ch = fgetc(fp);
  
  while(ch != EOF)
  {
    putchar(ch);
if( ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
        cnt++;
    ch = fgetc(fp);
  }

  printf("\n\nTotal vowels in given file = %d",cnt);
  return 0;
}

Output of Program

File content is : THIS IS TOP C PROGRAMMING PRACTICALS BLOG.

Total vowels in given file = 10


Wednesday, September 5, 2018

Computer Memory Units


Followings are basic computer memory units:
  • Bit - A Binary digit (Bit) is a smallest computer memory unit. It can hold 0 and 1.
  • Byte - Collection of 8 bits is called a Byte.


Symbols used in Computer Memory Units


Symbol
Prefix Name
Decimal Value
Binary Value
k
kilo
1000 
210 = 10241
M
mega
10002
220 = 10242
G
giga
10003
230 = 10243
T
tera
10004
240 = 10244
P
peta
10005
250 = 10245
E
exa
10006
260 = 10246
Z
zetta
10007
270 = 10247
Y
yotta
10008
280 = 10248

Memory Units Short forms
  • Byte = B
  • Kilobyte = KB
  • Megabytes = MB
  • Gigabytes = GB
  • Terabytes = TB
  • Petabytes = PB

Memory Units Conversion

Units
Conversion
 1 Byte
8 Bits 
 1 KB
1024 Bytes 
 1 MB
1024 KB 
 1 GB
1024 MB 
 1 TB
1024 GB 
 1 PB
1024 TB