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 | #include<iostream.h> #include<conio.h> long long value=1; class power { public: int base; int exp; void read() { cout<<"ENTER BASE NUMBER\n"; cin>>base; cout<<"ENTER EXPONENT NUMBER\n"; cin>>exp; } void find() { while(exp!=0) { value=value*base; exp--; } cout<<value; } }; void main() { clrscr(); power s; s.read(); s.find(); getch(); } |
Search This Blog
Thursday, 28 November 2013
FIND POWER OF A NUMBER.
PROGRAMM FOR BANKING OPERATTION DEPOSIT , WIDRWA AND SHOW CURENT BALANCE.
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 | #include<iostream.h> #include<conio.h> int flag=0; int dep=0; int wid=0; int balance=0; class bank { public: void deposit() { display(); cout<<"ENTER AMOUNT\n"; cin>>dep; balance=balance+dep; display(); } void widraw() { display(); if(balance>500) { cout<<"ENTER AMOUNT TO WIDRAW\n"; cin>>wid; } else { cout<<"\nACCCOUNT BALANCE IS LOW! "<<balance<<"\n"; } if(balance>wid) { if(balance-wid>=500) balance=(balance-wid); display(); } else { cout<<"TRANSACTION CANNOT PROCCEED INSUFFICIANT BALANCE\n"; display(); } } void display() { cout<<"CURRENT BALANCE: "<<balance<<"\n"; } }; void main() { if(flag==0) { clrscr(); } flag=1; bank s; int ch; cout<<"\n1:DEPOSIT\n2:WIDRAW\n3:SHOW BALANCE\n"; cin>>ch; switch(ch) { case 1 : s.deposit(); main(); break; case 2 : s.widraw(); main(); break; case 3 : s.display(); main(); break; } getch(); } |
LEANEAR SEARCH
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 | #include<iostream.h> #include<conio.h> int m[10]={8,4,8,5,6,4,7,8,7,8}; int n=10; int flag; class search { public: int i,el; void input() { cout<<"\nELEMENTS IN THE LIST\n"; for(i=0;i<n;i++) { cout<<m[i]<<","; } cout<<"\nENTER ELEMENT TO SEARCH\n"; cin>>el; } void se() { flag=1; for(i=0;i<n;i++) { if(m[i]==el) { cout<<"\nELEMENT "<<m[i]<<" FOUND AT LOCATION "<<i<<"\n"; flag=0; } } if(flag==1) { cout<<"SEARCH UNSUCCESSFUL\n"; } } }; void main() { clrscr(); search s; s.input(); s.se(); getch(); } |
CREATE TEXT FILE.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include<stdio.h> #include<iostream.h> #include<conio.h> void main() { char a[80]; cout<<"ENTER A STRING CHARACTER\n"; cin>>a; FILE *fp; //fp set pointer to FILE. fp=fopen("CPROGRAM.txt","a"); //syntax to create a text named "CPROGRAM.txt" file. fprintf(fp,"\n%s",a); //syntax to write data to "CPROGRAM.txt" file that u entred character. fclose(fp); //syntax to save this file. cout<<"FILE ""CPROGRAM"" IS CREATED\n To see this file check your TC/BIN location or location programm where ur stored this programm.\n"; getch(); } |
Subscribe to:
Posts (Atom)