Saturday, November 23, 2013
iPhone 6 Looks Awesome
Banking System
Banking System
Program:
#include<iostream>
#include<fstream>
#include<cstdlib>
using std::cout;
using std::cin;
using std::endl;
using std::fstream;
using std::ofstream;
using std::ifstream;
using std::ios;
class account_query
{
private:
char account_number[20];
char firstName[10];
char lastName[10];
float total_Balance;
public:
void read_data();
void show_data();
void write_rec();
void read_rec();
void search_rec();
void edit_rec();
void delete_rec();
};
void account_query::read_data()
{
cout<<"\nEnter Account Number: ";
cin>>account_number;
cout<<"Enter First Name: ";
cin>>firstName;
cout<<"Enter Last Name: ";
cin>>lastName;
cout<<"Enter Balance: ";
cin>>total_Balance;
cout<<endl;
}
void account_query::show_data()
{
cout<<"Account Number: "<<account_number<<endl;
cout<<"First Name: "<<firstName<<endl;
cout<<"Last Name: "<<lastName<<endl;
cout<<"Current Balance: Rs. "<<total_Balance<<endl;
cout<<"-------------------------------"<<endl;
}
void account_query::write_rec()
{
ofstream outfile;
outfile.open("record.bank", ios::binary|ios::app);
read_data();
outfile.write(reinterpret_cast<char *>(this), sizeof(*this));
outfile.close();
}
void account_query::read_rec()
{
ifstream infile;
infile.open("record.bank", ios::binary);
if(!infile)
{
cout<<"Error in Opening! File Not Found!!"<<endl;
return;
}
cout<<"\n****Data from file****"<<endl;
while(!infile.eof())
{
if(infile.read(reinterpret_cast<char*>(this), sizeof(*this))>0)
{
show_data();
}
}
infile.close();
}
void account_query::search_rec()
{
int n;
ifstream infile;
infile.open("record.bank", ios::binary);
if(!infile)
{
cout<<"\nError in opening! File Not Found!!"<<endl;
return;
}
infile.seekg(0,ios::end);
int count = infile.tellg()/sizeof(*this);
cout<<"\n There are "<<count<<" record in the file";
cout<<"\n Enter Record Number to Search: ";
cin>>n;
infile.seekg((n-1)*sizeof(*this));
infile.read(reinterpret_cast<char*>(this), sizeof(*this));
show_data();
}
void account_query::edit_rec()
{
int n;
fstream iofile;
iofile.open("record.bank", ios::in|ios::binary);
if(!iofile)
{
cout<<"\nError in opening! File Not Found!!"<<endl;
return;
}
iofile.seekg(0, ios::end);
int count = iofile.tellg()/sizeof(*this);
cout<<"\n There are "<<count<<" record in the file";
cout<<"\n Enter Record Number to edit: ";
cin>>n;
iofile.seekg((n-1)*sizeof(*this));
iofile.read(reinterpret_cast<char*>(this), sizeof(*this));
cout<<"Record "<<n<<" has following data"<<endl;
show_data();
iofile.close();
iofile.open("record.bank", ios::out|ios::in|ios::binary);
iofile.seekp((n-1)*sizeof(*this));
cout<<"\nEnter data to Modify "<<endl;
read_data();
iofile.write(reinterpret_cast<char*>(this), sizeof(*this));
}
void account_query::delete_rec()
{
int n;
ifstream infile;
infile.open("record.bank", ios::binary);
if(!infile)
{
cout<<"\nError in opening! File Not Found!!"<<endl;
return;
}
infile.seekg(0,ios::end);
int count = infile.tellg()/sizeof(*this);
cout<<"\n There are "<<count<<" record in the file";
cout<<"\n Enter Record Number to Delete: ";
cin>>n;
fstream tmpfile;
tmpfile.open("tmpfile.bank", ios::out|ios::binary);
infile.seekg(0);
for(int i=0; i<count; i++)
{
infile.read(reinterpret_cast<char*>(this),sizeof(*this));
if(i==(n-1))
continue;
tmpfile.write(reinterpret_cast<char*>(this), sizeof(*this));
}
infile.close();
tmpfile.close();
remove("record.bank");
rename("tmpfile.bank", "record.bank");
}
int main()
{
account_query A;
int choice;
cout<<"***Acount Information System***"<<endl;
while(true)
{
cout<<"Select one option below ";
cout<<"\n\t1-->Add record to file";
cout<<"\n\t2-->Show record from file";
cout<<"\n\t3-->Search Record from file";
cout<<"\n\t4-->Update Record";
cout<<"\n\t5-->Delete Record";
cout<<"\n\t6-->Quit";
cout<<"\nEnter your choice: ";
cin>>choice;
switch(choice)
{
case 1:
A.write_rec();
break;
case 2:
A.read_rec();
break;
case 3:
A.search_rec();
break;
case 4:
A.edit_rec();
break;
case 5:
A.delete_rec();
break;
case 6:
exit(0);
break;
default:
cout<<"\nEnter corret choice";
exit(0);
}
}
system("pause");
return 0;
}
Program:
#include<iostream>
#include<fstream>
#include<cstdlib>
using std::cout;
using std::cin;
using std::endl;
using std::fstream;
using std::ofstream;
using std::ifstream;
using std::ios;
class account_query
{
private:
char account_number[20];
char firstName[10];
char lastName[10];
float total_Balance;
public:
void read_data();
void show_data();
void write_rec();
void read_rec();
void search_rec();
void edit_rec();
void delete_rec();
};
void account_query::read_data()
{
cout<<"\nEnter Account Number: ";
cin>>account_number;
cout<<"Enter First Name: ";
cin>>firstName;
cout<<"Enter Last Name: ";
cin>>lastName;
cout<<"Enter Balance: ";
cin>>total_Balance;
cout<<endl;
}
void account_query::show_data()
{
cout<<"Account Number: "<<account_number<<endl;
cout<<"First Name: "<<firstName<<endl;
cout<<"Last Name: "<<lastName<<endl;
cout<<"Current Balance: Rs. "<<total_Balance<<endl;
cout<<"-------------------------------"<<endl;
}
void account_query::write_rec()
{
ofstream outfile;
outfile.open("record.bank", ios::binary|ios::app);
read_data();
outfile.write(reinterpret_cast<char *>(this), sizeof(*this));
outfile.close();
}
void account_query::read_rec()
{
ifstream infile;
infile.open("record.bank", ios::binary);
if(!infile)
{
cout<<"Error in Opening! File Not Found!!"<<endl;
return;
}
cout<<"\n****Data from file****"<<endl;
while(!infile.eof())
{
if(infile.read(reinterpret_cast<char*>(this), sizeof(*this))>0)
{
show_data();
}
}
infile.close();
}
void account_query::search_rec()
{
int n;
ifstream infile;
infile.open("record.bank", ios::binary);
if(!infile)
{
cout<<"\nError in opening! File Not Found!!"<<endl;
return;
}
infile.seekg(0,ios::end);
int count = infile.tellg()/sizeof(*this);
cout<<"\n There are "<<count<<" record in the file";
cout<<"\n Enter Record Number to Search: ";
cin>>n;
infile.seekg((n-1)*sizeof(*this));
infile.read(reinterpret_cast<char*>(this), sizeof(*this));
show_data();
}
void account_query::edit_rec()
{
int n;
fstream iofile;
iofile.open("record.bank", ios::in|ios::binary);
if(!iofile)
{
cout<<"\nError in opening! File Not Found!!"<<endl;
return;
}
iofile.seekg(0, ios::end);
int count = iofile.tellg()/sizeof(*this);
cout<<"\n There are "<<count<<" record in the file";
cout<<"\n Enter Record Number to edit: ";
cin>>n;
iofile.seekg((n-1)*sizeof(*this));
iofile.read(reinterpret_cast<char*>(this), sizeof(*this));
cout<<"Record "<<n<<" has following data"<<endl;
show_data();
iofile.close();
iofile.open("record.bank", ios::out|ios::in|ios::binary);
iofile.seekp((n-1)*sizeof(*this));
cout<<"\nEnter data to Modify "<<endl;
read_data();
iofile.write(reinterpret_cast<char*>(this), sizeof(*this));
}
void account_query::delete_rec()
{
int n;
ifstream infile;
infile.open("record.bank", ios::binary);
if(!infile)
{
cout<<"\nError in opening! File Not Found!!"<<endl;
return;
}
infile.seekg(0,ios::end);
int count = infile.tellg()/sizeof(*this);
cout<<"\n There are "<<count<<" record in the file";
cout<<"\n Enter Record Number to Delete: ";
cin>>n;
fstream tmpfile;
tmpfile.open("tmpfile.bank", ios::out|ios::binary);
infile.seekg(0);
for(int i=0; i<count; i++)
{
infile.read(reinterpret_cast<char*>(this),sizeof(*this));
if(i==(n-1))
continue;
tmpfile.write(reinterpret_cast<char*>(this), sizeof(*this));
}
infile.close();
tmpfile.close();
remove("record.bank");
rename("tmpfile.bank", "record.bank");
}
int main()
{
account_query A;
int choice;
cout<<"***Acount Information System***"<<endl;
while(true)
{
cout<<"Select one option below ";
cout<<"\n\t1-->Add record to file";
cout<<"\n\t2-->Show record from file";
cout<<"\n\t3-->Search Record from file";
cout<<"\n\t4-->Update Record";
cout<<"\n\t5-->Delete Record";
cout<<"\n\t6-->Quit";
cout<<"\nEnter your choice: ";
cin>>choice;
switch(choice)
{
case 1:
A.write_rec();
break;
case 2:
A.read_rec();
break;
case 3:
A.search_rec();
break;
case 4:
A.edit_rec();
break;
case 5:
A.delete_rec();
break;
case 6:
exit(0);
break;
default:
cout<<"\nEnter corret choice";
exit(0);
}
}
system("pause");
return 0;
}
Wednesday, November 20, 2013
Love Calculator
Program:
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
int i,l1;
long int s1,s2,t;
char name1[50],name2[50];
void title(),del();
clrscr();
title();
printf("\nTest your Love percentage");
delay(5000);
clrscr();
title();
printf("\nEnter Boy name:");
scanf("%s",name1);
printf("\nEnter Girl name:" );
scanf("%s",name2);
printf("Please wait Calculating.");
for(i=0;i<8;i++)
{
del();
}
clrscr();
title();
printf("Calculation completed");
delay(1000);
clrscr();
title();
printf("Press any key to view result");
l1=0;
for(i=0;i<50;i++)
{
if(name1[i]!='\0')
{
l1++;
continue;
}
break;
}
s1=0;
for(i=0;i<l1;i++)
{
s1=s1+name1[i];
}
getch();
l1=0;
for(i=0;i<50;i++)
{
if(name2[i]!='\0')
{
l1++;
continue;
}
break;
}
s2=0;
for(i=0;i<l1;i++)
{
s2=s2+name2[i];
}
t=s1+s2;
while(t>100)
{
t=t/10;
}
clrscr();
title();
printf("the result is %ld%",t);
getch();
}
void title()
{
printf("\nLove Calculator");
}
void del()
{
delay(500);
printf("---");
}
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
int i,l1;
long int s1,s2,t;
char name1[50],name2[50];
void title(),del();
clrscr();
title();
printf("\nTest your Love percentage");
delay(5000);
clrscr();
title();
printf("\nEnter Boy name:");
scanf("%s",name1);
printf("\nEnter Girl name:" );
scanf("%s",name2);
printf("Please wait Calculating.");
for(i=0;i<8;i++)
{
del();
}
clrscr();
title();
printf("Calculation completed");
delay(1000);
clrscr();
title();
printf("Press any key to view result");
l1=0;
for(i=0;i<50;i++)
{
if(name1[i]!='\0')
{
l1++;
continue;
}
break;
}
s1=0;
for(i=0;i<l1;i++)
{
s1=s1+name1[i];
}
getch();
l1=0;
for(i=0;i<50;i++)
{
if(name2[i]!='\0')
{
l1++;
continue;
}
break;
}
s2=0;
for(i=0;i<l1;i++)
{
s2=s2+name2[i];
}
t=s1+s2;
while(t>100)
{
t=t/10;
}
clrscr();
title();
printf("the result is %ld%",t);
getch();
}
void title()
{
printf("\nLove Calculator");
}
void del()
{
delay(500);
printf("---");
}
Tuesday, November 19, 2013
Run C program in Android Platform - C4droid
C4droid --> C for Android
Download Links:
C4droid #1 filesear
C4droid #2 Zippyshare
C4droid #3 Sendspace
C4droid #4 Howfile
Description
C4droid is a user-friendly (but powerful) C/C++ IDE + C/C++ compiler for Android. Note that C4droid supports devices with ARM processors only (not devices with Intel x86 or MIPS processor).
Basic features:
- Offline compiler: create your own applications on Android device and run them even without Internet access
- No root required (but C4droid can use it for your programs if you want)
- Full ANSI C and ISO C99 support with TCC + uClibc
- Source code editor with syntax highlighting, tabs, code completion, code formatting, file association and infinite undo/redo
- Export&share your programs as APKs or native executables (for terminal apps)
More features with a free GCC plugin:
- Full C++ and almost complete C++11 support with GCC + Bionic libc
- NativeActivity, Qt, SDL and SDL2 support for GUI
- The most recent version of GCC always available
- Makefile support: use the same build scripts as on your PC (BusyBox is included)
- Semi-automatic open-source library porting feature for enhanced programming & education
C4droid is designed to be user-friendy out-of-the-box, but nothing is perfect, so here are some answers for questions that can appear:
How to install C++ support?
C4droid will ask you to install C++ support at first startup and will configure itself in semi-automatic mode.
If you want to do that manually, you need:
0) Enough internal memory OR root rights. C4droid does not require root rights for devices with more than 50MB of free internal memory.
1) Install GCC plugin (C4droid will ask you to install it).
2) Select G++ compiler in C4droid preferences.
3*) Use iostream, not iostream.h
4*) Add "using namespace std;" to your program (before int main)
How to use SDL, SDL2, NativeActivity and Qt in single-file mode?
Just install SDL plugin and select G++ compiler in C4droid preferences.
Note that C4droid chooses app mode using a very simple source code analysis:
SDL is detected with #include "SDL.h", SDL2 is detected with #include "SDL2/SDL.h", NativeActivity is detected with #include "android_native_app_glue.h", Qt is detected with #include "QtGui"
If you are compiling a single-file Qt app, you must add #include "yoursourcefilenamewithcpp.moc" to the end of source code file also.
How to use Makefiles, multifile projects, etc?
Long-click compile button (or select "compilation settings" if buttons are hidden/moved) and configure current directory to use the mode you want.
Note that C4droid will create .c4droid configuration file when you will press Ok. Some modes (like makefile) require to enter result executable file name, don't forget to do that.
After doing that all use compile and run buttons to build and run your app as regular.
How to build and install libraries?
Almost the same way as regular Makefile building except for that most probably some patching may be required.
Currently tested libraries are gmp(internal memory only),mpfr,mpc,libxml2,neon,sqlite,SDL_gfx(--disable-mmx required).
Which gestures/keyboard shortcuts does C4droid support?
Long-click gestures:
Save button: save as.
Open button: recent files.
Run button: run with arguments.
Compile button: configure current directory.
Tab: close tab.
Keyboard shortcuts:
Ctrl-C, Ctrl-V, Ctrl-X for Copy, Paste and Cut
Ctrl-S, Ctrl-O for Save/Open
Ctrl-Z, Ctrl-Y for Undo/Redo.
Ctrl-L for "go to Line"
Ctrl-F for Find
Ctrl-A for select All
Ctrl-B for Build/compile
Ctrl-R for Run
Ctrl-Space/Ctrl-D for autocompletion (Ctrl-Space may be reserved by Android)
If you have found some bugs or you want more help, contact me.
C4droid will check license via the Internet, make sure to have a correct Google Play app (not patched or hacked).
Report bugs at n0n3m4@gmail.com.
Some binaries contained in APK are licensed under (L)GPL, email me to get the source code (Tiny C compiler, GCC, BusyBox, etc.)
Android is a trademark of Google Inc.
Qt is a registered trademark of Digia.
Download Links:
C4droid #1 filesear
C4droid #2 Zippyshare
C4droid #3 Sendspace
C4droid #4 Howfile
Description
C4droid is a user-friendly (but powerful) C/C++ IDE + C/C++ compiler for Android. Note that C4droid supports devices with ARM processors only (not devices with Intel x86 or MIPS processor).
Basic features:
- Offline compiler: create your own applications on Android device and run them even without Internet access
- No root required (but C4droid can use it for your programs if you want)
- Full ANSI C and ISO C99 support with TCC + uClibc
- Source code editor with syntax highlighting, tabs, code completion, code formatting, file association and infinite undo/redo
- Export&share your programs as APKs or native executables (for terminal apps)
More features with a free GCC plugin:
- Full C++ and almost complete C++11 support with GCC + Bionic libc
- NativeActivity, Qt, SDL and SDL2 support for GUI
- The most recent version of GCC always available
- Makefile support: use the same build scripts as on your PC (BusyBox is included)
- Semi-automatic open-source library porting feature for enhanced programming & education
C4droid is designed to be user-friendy out-of-the-box, but nothing is perfect, so here are some answers for questions that can appear:
How to install C++ support?
C4droid will ask you to install C++ support at first startup and will configure itself in semi-automatic mode.
If you want to do that manually, you need:
0) Enough internal memory OR root rights. C4droid does not require root rights for devices with more than 50MB of free internal memory.
1) Install GCC plugin (C4droid will ask you to install it).
2) Select G++ compiler in C4droid preferences.
3*) Use iostream, not iostream.h
4*) Add "using namespace std;" to your program (before int main)
How to use SDL, SDL2, NativeActivity and Qt in single-file mode?
Just install SDL plugin and select G++ compiler in C4droid preferences.
Note that C4droid chooses app mode using a very simple source code analysis:
SDL is detected with #include "SDL.h", SDL2 is detected with #include "SDL2/SDL.h", NativeActivity is detected with #include "android_native_app_glue.h", Qt is detected with #include "QtGui"
If you are compiling a single-file Qt app, you must add #include "yoursourcefilenamewithcpp.moc" to the end of source code file also.
How to use Makefiles, multifile projects, etc?
Long-click compile button (or select "compilation settings" if buttons are hidden/moved) and configure current directory to use the mode you want.
Note that C4droid will create .c4droid configuration file when you will press Ok. Some modes (like makefile) require to enter result executable file name, don't forget to do that.
After doing that all use compile and run buttons to build and run your app as regular.
How to build and install libraries?
Almost the same way as regular Makefile building except for that most probably some patching may be required.
Currently tested libraries are gmp(internal memory only),mpfr,mpc,libxml2,neon,sqlite,SDL_gfx(--disable-mmx required).
Which gestures/keyboard shortcuts does C4droid support?
Long-click gestures:
Save button: save as.
Open button: recent files.
Run button: run with arguments.
Compile button: configure current directory.
Tab: close tab.
Keyboard shortcuts:
Ctrl-C, Ctrl-V, Ctrl-X for Copy, Paste and Cut
Ctrl-S, Ctrl-O for Save/Open
Ctrl-Z, Ctrl-Y for Undo/Redo.
Ctrl-L for "go to Line"
Ctrl-F for Find
Ctrl-A for select All
Ctrl-B for Build/compile
Ctrl-R for Run
Ctrl-Space/Ctrl-D for autocompletion (Ctrl-Space may be reserved by Android)
If you have found some bugs or you want more help, contact me.
C4droid will check license via the Internet, make sure to have a correct Google Play app (not patched or hacked).
Report bugs at n0n3m4@gmail.com.
Some binaries contained in APK are licensed under (L)GPL, email me to get the source code (Tiny C compiler, GCC, BusyBox, etc.)
Android is a trademark of Google Inc.
Qt is a registered trademark of Digia.
Subscribe to:
Posts (Atom)