Skip to main content

Posts

Showing posts from July, 2011

characteristic of Pythagorean

The sum of two numbers is a square. The sum of their squares is also a square. Find a method to get all such numbers. Answer let a + b = x^2 and a^2 + b^2 = y^2. the second equation is the characteristic Pythagorean triplet. so we can write a and b as p^2-1 and 2p where p is a positive integer > 1 . therefore, (p^2-1) + (2p) has to be a square number. [which is not true except for p=1/2] thus there is no base Pythagorean triplet which satisfies this relation, but multiples of them may easily do so. like: 3,4,5. 3+4 = 7 not a square. but for 21,28,35. 21 + 28 =7^2. thus (p^2+2p-1)(p^2-1) and (p^2+2p-1)(2p) or better still, q^2*(p^2+2p-1)(p^2-1) and q^2*(p^2+2p-1)(2p) satisfy the given condition, where p,q are both positive integers.

Properties of Irrational numbers

Properties of Irrational numbers If x be an irrational number then there are infinitely many relatively prime integers p and q such that | p/q - x | < 1/q^2 If x is a rational number then there are finitely many solutions to the above equation. This Theorem was first discovered by Dirichlet Further let {y} be the fractional part of y. x is an irrational number then the sequence {nx} n = 1,2,3, ... is not periodic. If x is a rational then this sequence is periodic. A rational number can be represented only by a a finite continued fraction where as an irrational number can be represented by an infinite continued fraction. Each convergent of the continued fraction representation of a irrational number is a better rational approximation of the given irrational number, than any previous convergent. Eg: The continued fraction representation of Pi is [3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, ..] hence the successive rational approximation of Pi are 3, 2

fibonacci numbers in pascal's triangle

Fibonacci numbers in pascal's triangle? The Proof follows from the following identity: Let F(r) be the r-Th Fibonacci number, C(n,r) be the number of combination of n things taken are at a time and [x] be the greatest integer function then Summation C(n-k, k) = F(n+1) where k goes form k=0 to k = [n/2] Now use induction on the variable n.

Improve your reasoning power and Solve the Mathematics equation problem

Improve your reasoning power Question - When a no. is divided by 2, rem. is 1 when divided by 3, rem. is 2. and so on...till it is divided by 10, remainder is 9.What's the number? Answer- if the no. be n, (n+1) is divisible by all of {2,3,4,..,10}. hence (n+1) is divisible by 2520. [ 2 |(n+1) & 3 |(n+1) => 6 |(n+1) & 4 | (n+1) => 12 |(n+1) (12=l.c.m(6,4)) & 5 |(n+1) => 60 |(n+1). continuing in this way 2520 |(n+1)] therefore any no. of the form n=(2520p-1) will suffice where p is a natural no. of course the smallest such natural no. is 2519. Mathematics equation problem X^3-Y^2=2 FIND ALL INTEGRAL SOLUTION OF X,Y Answer: case 1 x-3=y-5 y=x+2 original eq gives x^3-x^2-4x-2=0 no integral solution for this. case 2 x-3=y+5 y=x-8 original eq gives x^3-x^2+16x-66=0 (x-3)(x^2+2x+22)=0 x=3 y=-5 as eq invoves y^2 hence y as wellas -y both satisfies the pairs are (3,5) and (3,-5)

Find the remainder

Find the remainder when the digits 1 to 99 written side by side is divided by 11 i.e: (123456789101112...99)mod 11=? 123456789101112.....979899 counting from right, sum of digits at odd place = 9(9+8+...+1+0)+(9+7+5+3+1) sum of digits at even place = 10(9+8+...+1)+(8+6+4+2) sum of odd - sum of even = -40 = 4 (mod 11)

Code to send email using PLSQL

Code to send email using PLSQL You can use UTL_SMTP and UTL_TCP to send email attachment from Oracle Version 8i onwards. Sample Code: DECLARE v_From VARCHAR2(80) := 'oracle@mycompany.com'; v_Recipient VARCHAR2(80) := 'test@mycompany.com'; v_Subject VARCHAR2(80) := 'test subject'; v_Mail_Host VARCHAR2(30) := 'mail.mycompany.com'; v_Mail_Conn utl_smtp.Connection; crlf VARCHAR2(2) := chr(13)||chr(10); BEGIN v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25); utl_smtp.Helo(v_Mail_Conn, v_Mail_Host); utl_smtp.Mail(v_Mail_Conn, v_From); utl_smtp.Rcpt(v_Mail_Conn, v_Recipient); utl_smtp.Data(v_Mail_Conn, 'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf || 'From: ' || v_From || crlf || 'Subject: '|| v_Subject || crlf || 'To: ' || v_Recipient || crlf || 'MIME-Version: 1.0'|| crlf || -- Use MIME mail standard 'Content-Type: multi

Code to Get all table size in sql database server, code to get table size, get sql tables size, show table size in sql server

SET NOCOUNT ON DBCC UPDATEUSAGE(0) -- Database size. Following code you can write in stored procedure or you can directly run on query browser to get all table size in selected database. EXEC sp_spaceused-- Table row counts and sizes. CREATE TABLE #test ( [name] NVARCHAR(128), [rows] CHAR(11), reserved VARCHAR(18), data VARCHAR(18), index_size VARCHAR(18), unused VARCHAR(18)) INSERT #t EXEC sp_msForEachTable 'EXEC sp_spaceused ''?''' SELECT *FROM #test-- # of rows. SELECT SUM(CAST([rows] AS int)) AS [rows]FROM #test DROP TABLE #test I hope this code will help you a lot on database administration.

Code to check your PC name

Set VObj = CreateObject("SAPI.SpVoice") with VObj Set .voice = .getvoices.item(0) .Volume = 100 .Rate = 1 end with Set VObj = CreateObject("SAPI.SpVoice") For Each Voice In VObj.getvoices I = I + 1 msgbox "I am " & Voice.GetDescription & " and ;)" Next For count=0 to 3 vobj.Speak"Cygig Lol, at least try to do it in a less obvious way" Next

how to Print starik triangle in c++

To Print starik triangle in c++ like this way ********** ********* ******** ******* ****** ***** **** *** ** * You can write following code in c++ editor. void main(){ const int size=10,x=0; for(int i=0;i<size;++i) { cout<<"\n"; for(int j=0;j<size-x;++j) cout<<"*"; for(int k=0;k<x;++k) cout<<" "; ++x; } getch(); }

How to use strcpy with malloc function

char s[]="Hello" is an array of chars char *s[] = "asa"; is an error coz itz an array of character pointers char *s[] = { "AAA", "BBB", "CCC"}; is OK --------------- char s[]="ABCD" char (*p)[5] = &s; //is fine... here p is a pointer to an array ------ In Your case... U cn do this char s[] = "Hello" char *p[2]; p[0] = (char *)malloc(sizeof(s)); strcpy(p[0], s); p[1] = (char *)malloc(sizeof(s)); strcpy(p[1], s);

Program for largest element in array using c++

Program for largest element in array using c++ int array[5],i,temp; printf("\n enter element in array"); for(i=0;i<5;i++) scanf("%d",&array); for(i=1;i<5;i++) { if(array[0]) { temp=array; array=array[0];array[0]=temp; } } printf("\n largest ele. in array=%d",temp); getch(); } we get array size 5 then enter 5 element in array..then tack temp variable before this we give separate 1st element in array to assign maximum element in array then compare it with one by one remaining element in array..if 1st ele in array is smaller than any one element in remaining array then print element in remaining array..else print 1st element in array. Deletes all array elements in c++ #include class Date { int mo, da, yr; public: Date() { std::cout << "Date constructor" << std::endl; } ~Date() { std::cout << "Date destructor" << std::endl;

Code to generate the pyramid structure using c++

Code to generate the pyramid structure using c++ main() { int i; int j,n,uppr,lowr, arry[] = {1,2,3,4,5,6,7,8,9}; /*Take Input */ do { cout << "Enter an odd number(0-9):"; cin >> n; if(n < 0 || n > 9 || ((n % 2) == 0)) cerr << "Error" << endl; }while(n < 0 || n > 9 || ((n % 2) == 0)); /*Generate the pyramid structure */ for(i = 0; i < n; i++) { for(j = 0; j < ((i < (n-i-1)?i:(n-i-1))); j++) cout << " "; lowr = (i < (n-i-1)) ? i : (n-i-1); uppr = (i < (n-i-1)) ? (n-i-1) : i; for( j = lowr; j <= uppr; j++) cout << arry[j]; cout << endl; } return 0; } To execute something before main function you can try below code fun() { clrscr(); printf("\nIn the fun.........."); } #pragma startup fun int main() { printf("\nIn the main()"); getch(); return 0; }

Difference between Visual C++ and Visual C++.NET

Difference between Visual C++ and Visual C++.NET VC++ is only the "single user system GUI" i.e the program or application written in VC++ are to be installed in each machine to use that. While VC++.NET is the "Networked or Web based gui" i.e The program or application written in VC++.NET need not be installed in each machine but it will be in the server and all other machines can use that application by "DOMAIN NAME" or "IP address .NET programmes are made available in the Internet or globally by making use of any servers i.e "Apache server" "Jboss server" "Web logic" all the .NET programme files are put in any of these servers and using IP address this programmes can be accessed. VC++ is a compiler for C/C++ and all and not a language in itself, but the WIN32 platform offers so much applications in itself that it is a almost new world. As far as my decision of going with VC++ 6.0 and VC++.NET is that the bo

difference between locally and globally static variables.

Difference between locally and globally static variables. 1) Global Static variables are initialized at the beginning of the program. Local Static variables are initialized only when the function containing the variable is called. 2) Local Static variable is accessed by only the function in which it is declared. Global Static variable can be accessed by all the function in the program (with in a file in which they declared). 3) Global Static variables are not accessed by any other file. Local Static variables are not accessed from outside the function in which they declared.

print any real number and print the integer part and the real part separately without using modulus

print any real number and print the integer part and the real part separately without using modulus class date { int dd,mm,yy; public: void input() { cout<<"Enter the date :"<>dd; cout<<"Enter the month :"; cin>>mm; cout<<"Enter the year :"; cin>>yy; } void calc() {int n,p; cout<<"Enter the number of days"<>n; dd=dd+n; if(dd>30) {mm=mm+(dd%30); dd=dd+(dd/30); } if(mm>12) yy=yy+(mm%12) } void display() { cout<<"The new date="<<dd<<"/"<<mm<<"/"<<yy<<endl; } }; void main() {clrscr(); date d; d.input(); d.calc(); d.display(); getch(); }

Display all palindromes in one single string entered by user using c++

void main() { long i,j,n,k,l,v; int flag,u=0,y,x; int shaff[10],shaff1[720][4]; char pal[14],pal1[720][14],word[14]; clrscr(); cout<<"enter the palentrom\n"; gets(pal); strcpy(pal1[0],pal); strrev(pal1[0]); if(strcmp(pal1[0],pal)!=0) { cout<<"entered value is not palaentrom\n"; getch(); exit(0); } y=strlen(pal); if(y%2==0) n=y/2; if(y%2==1) n=(y-1)/2; k=0; for(i=0;i=0;i--) l=l*10+i; for(i=k;i<=l;i++) { v=i; for(j=0;j=n) flag=0; } v=i; if(flag==1) { for(j=0;j[j]=v%10; v=v/10; } u++; } } l=1; for(i=0;i[j]]; x++; } if(y%2==1) { word[x]=pal[n]; x++; } for(j=n-1;j>=0;j--) { word[x]=pal[shaff1[j]]; x++; } word[x]='\0'; flag=1; for(k=0;k<=l;k++) { if(strcmp(pal1[k],word)==0) flag=0; } if(flag==1) { strcpy(pal1[l],word); l++; } } cout<<"

declaration of friend classes ,size of heap in c++

Declaration of friend classes class XYZ { int x; public: }; class ABC { int y; public: friend class XYZ; }; ///////////// class ABC; //forward declaration class XYZ { int x; public: void fun(){ ... ABC tmp; ... tmp.y=10; //legal } }; class ABC { int y; public: friend class XYZ; void fun() { ... XYZ tmp; ... //tmp.y=10; Illegal } }; //Size of heap in c++ #include #include int main() { char *a=(char *)0; int (*fun)()=main; printf("%u ",fun); return(0); }

Bank project example using c++

Bank project example using c++ #include #include"fstream.h" using std::cout; using std::cin; class BankUser{ public: BankUser(); void viewBalance(); void deposit(); void withdraw(); double transfer1(); void transfer2(double); private: double blance; }; BankUser::BankUser() { char type; cout<<"enter the type for this Account"; cout<<"\n\ncheck Account :C"; cout<<"\nSaving Account :S"; cout<<"\n\n\ Enter ur Choice :"; cin>>type; if (type=='S'||type=='S') blance=1500; else blance=1000; } void BankUser::viewBalance() { cout<<"\n The Current Blane Of This Account Is="<>amount; blance+=amount; if(blance>2000) blance+=50; viewBalance(); } void BankUser::withdraw() { double amount; cout<<"Enter the Amount to be with drawn :"; cin>>

example of random and randomize function in c++

example of random and randomize function in c++ void main() { randomize(); int k; int vett[90]; clrscr(); for (int i=0; i<90; i++) { do { vett=random(90)+1; k=0; while (vett!=vett[k]) k++; } while(k!=i); } cout<<"?????????"; cout<<"\n"; for (int j=0; j<90; j++) cout<<""<<vett[j]<<" "; int tab[91]; int h; int val; int u=0; for (int l=0; l<90; l++) { h=random(90-u); val=vett[h]; vett[h]=vett[90-u]; tab[val]=val; u++; } cout<<"\n"; cout<<"after ...........????"; cout<<"\n"; for (int y=1; y<91; y++) cout<<""<<tab[y]<<" "; getch(); }

Dynamic cast using c++

Dynamic cast using c++ dynamic_cast() is more useful to find out what kind of object is pointed to by the given pointer. This is used when you write a function that could accept any objects of the given class's hierarchy and then you take care of it inside the method. Like, function myMethod(Base *ptr) // can recognize any object that is of Base's family { if (dynamic_cast(ptr) != NULL) // the pointed-to object is of Child1 { Child1 *myChild = ptr; // here you take care of it as it is of a Child1 object // .. rest of the code } else if (dynamic_cast(ptr) != NULL) // the pointed-to object is of Child2 { Child2 *myChild = ptr; // here you take care of it as it is of a Child2 object // .. rest of the code } else if (dynamic_cast(ptr) != NULL) // the pointed-to object is of Child3 { Child3 *myChild = ptr; // here you take care of it as it is of a Child3 object // .. rest of the code } else { // the object pointed-to by ptr is not Base's class family/

Object Slicing in c++

"If b is a base class pointer and d is a derived class pointer then b=d will copy only the base class contents and remove the derived class contents.This is known as Object Slicing and should be avoided." class bc { public: int a; float b; }; class dc : public bc { public: char c; }; main() { bc Bobj; //Bobj contains int a and float b dc Dobj; //Dobj contains int a, float b and char c Bobj=Dobj; // when we assign dc class obj to a bc class obj it slices of dc portion of obj so a and b get copied into a and b of Bobj and char c does not get copied in effect Dobj got sliced }

Object oriented programming language (OOPL) and Run time Polymorphism

Object oriented programming language (OOPL) What is object in c++ Objects are the foundation of object-oriented programming, and are fundamental data types in object-oriented programming languages. These languages provide extensive syntactic and semantic support for object handling, including a hierarchical type system, special notation for declaring and calling methods, and facilities for hiding selected fields from client programmers. However, objects and object-oriented programming can be implemented in any language. C++ Carry's the concept of object oriented programming 1) data abstraction 2) data encapsulation 3) modularity 4) inheritance 5) polymorphism C++ is an OOPL not just because it supports the OOPS concepts but more importantly, those concepts are EASY to implement in C++, and sometimes some non OOPS concepts are difficult to do. For example, it is possible to implement data hiding etc using C, but they are unusually difficult, whereas C++ directly

Templates versus Inheritance

Programmers sometimes find it tricky to decide whether to use templates or inheritance. Here are some tips to help you make the decision. Use templates when you want to provide identical functionality for different types. For example, if you want to write a generic sorting algorithm that works on any type, use templates. If you want to create a container that can store any type, use templates. The key concept is that the templatized structure or algorithm treats all types the same. When you want to provide different behaviors for related types, use inheritance. For example, use inheritance if you want to provide two different, but similar, containers such as a queue and a priority queue. Inheritance gets quite useful when designing user interface components -- e.g. when your Application Window inherits from general Window (this type of relationship is called is-a relationship and it's one of the major uses of inheritance). Similarly for mathematical applications -- say, yo

what is DIAMOND problem in C++

Ex: Diamond Inheritance Problem in figure form. -------------A ----------> A is the Base Class containing init() ------------/-\ -----------/---\ ----------/-----\ ---------B------C -------> B and C are the derived from A so.. init() is also derived ----------\-----/ both classes -----------\---/ ------------\-/ -------------D-------------> D is derived from B and C (MULTIPLE INHERITANCE), so multiple init() method is also inherited. Here D get ambiguous state to access init() method...i.e init() from B? or init() from C? Sol :: We can resolve this diamond problem by two ways i.e. By using 1) By using :: (Scope resolution operator) w.r.t to the class name 2) By declaring the classes as Virtual Class.

why addition of pointer is not possible

why addition of pointer is not possible Pointer are actually a variable with 2bytes of memories and it stores the address of any another variable ..so value stored in pointer will be the address and not the value of that variable.. for example: suppose int a =5; int *p=&a; and address of a is 115 and tht of p is 225... now the above code states tht value of a = 5; value of p = 115;//address of a

What are benefit of function pointer?

There are many many uses of function pointers ranging from simple ones to complex scenarios. One example in C++ domain is implementation of virtual functions using vtable. vtable is one of the methods to implement virtual functions in C++. This uses function pointers. Other good example are the scenario where you dynamically load a shared library. Once the application loads the library, it calls the functions defined in that library using function pointers. many of the sort algorithms take function pointer as an argument and call that function pointer to perform the comparison between two entities. At an enterprise level, an Application which is a transaction monitor (i.e which support online transactions), communication with difference databases using a well known standard called XA interface. This communication happens using function pointers. Advantage here is that the application need not be aware of how various databases implement their commit or rollback functions.

SQL Injection Attack

SQL Injection Attack  It is a basically a trick to inject SQL command or query as a input mainly in the form of the POST or GET method in the web pages. Most of the websites takes parameter from the form and make SQL query to the database. For a example, in a product detail page of php, it basically takes a parameter product_id from a GET method and get the detail from database using SQL query. With SQL injection attack, a intruder can send a crafted SQL query from the URL of the product detail page and that could possibly do lots of damage to the database. And even in worse scenario, it could even drop the database table as well.e SQL injection is a technique often used to attack a website. This is done by including portions of SQL statements in a web form entry field .

What are the disadvantages of select() on unix

What are the disadvantages of select() on unix One traditional way to write network servers is to have the main server block on accept(), waiting for a connection. Once a connection comes in, the server fork()s, the child process handles the connection and the main server is able to service new incoming requests. With select(), instead of having a process for each request, there is usually only one process that "multi-plexes" all requests, servicing each request as much as it can. So one main advantage of using select() is that your server will only require a single process to handle all requests. Thus, your server will not need shared memory or synchronization primitives for different 'tasks' to communicate. One major disadvantage of using select(), is that your server cannot act like there's only one client, like with a fork()'ing solution. For example, with a fork()'ing solution, after the server fork()s, the child process works with the client

Books to improve English grammar and vocabulary

Books to improve English grammar and vocabulary GRAMMAR 1)COLLINS COBUILD ENGLISH GRAMMAR 2)HOW TO WRITE CORRECT ENGLISH BY R.P SINHA(BOTH IN HINDI AND ENGLISH) 3)ENGLISH GRAMMAR BY TONDON & TONDON 4)HIGH SCHOOL ENGLISH GRAMMAR AND COMPOSITION BY WREN ANS MARTIN 5) PRACTICAL ENGLISH GRAMMAR BY THOMSON AND MARTINET VOCABULARY 1)OXFORD ,WEBSTER,CHAMBERS,CAMBRIDGE AND LONGMAN(ANY ONE MAY BE CHOOSEN) 2)ALL ABOUT WORDS BY MAXWELL NURNBERG 3)WORD POWER MADE EASY BY NORMAN LEWIS 4)SIX WEEKS TO WORD POWER BY WILFED FUNK 5)30 DAYS TO A MORE POWER VOCABULARY BY WILFRED FUNK 6)BARRONS WORD LIST 7)READERS DIGEST

importance of certificate credentials

Importance of certificate credentials There are lots of competition in today’s IT field because of lots of colleges who produces a huge number of engineers. To stand somewhere students have to do some thing extra. Many of the students wants to do career courses in parallel to their studies or after their studies. Suddenly the bunch of question arises like which course to do, from where to do, how to do, who is trustful education provider, etc. Students don’t get in-depth knowledge in any area in their regular studies because they have huge course and they are more concerned to pass their exams. They are not much concerned to have in-depth knowledge in specific field. Companies can’t hire fresher’s for the process with out giving them training. But in the current situation when companies are cutting their cost, they are not hiring fresher’s in bulk. They only hire those students who are having extra specific knowledge.

Java Archive files

Java Archive files allow developers to package many classes into a single file. JAR files also use compression, so this can make applets and applications smaller. Creating a .JAR file is easy. Simple go to the directory your classes are stored in and type :- jar -cf myfile.jar *.class If your application or applet uses packages, then you'll need to do things a little differently. Suppose your classes were in the package mycode.games.Cool Game - you'd change to the directory above mycode and type the following :- jar -cf myfile.jar .\mycode\games\CoolGame\*.class Now, if you have an existing JAR file, and want to extract it, you'd type the following jar -xf myfile.jar Working with JAR files isn't that difficult, especially if you've used the UNIX 'tar' command before. If you're planning on packaging an applet for Internet Explorer, or an application for Microsoft's jview, you might also want to consider .CAB files.

Domain Name Extensions and Meanings

.com..........................commercial .edu..........................educationa l and research .gov..........................government .int............................internat ional organizations .mil...........................military agency .net..........................gateway or host .org.........................non-profit organization

Sharing printer between two PC

Sharing printer between two PC In the first PC where the printer is connected & installed. 1. In windows explorer - Go to Tools>Option>View. 2. Enable "use simple file sharing (recommended). 3. Go to Start>Settings>Printers & Faxes 4. Right click the Printer - click Sharing 5. Click Share this printer and Click List in Directory 7. Click Apply In the second PC where the printer to be installed. 1. Go to Start>Settings>Printers & Faxes 2. Click Add a Printer>Click Next 3. Click Network Printer.>Click Next 4. Click Find a Printer in the Directory>Click Next 5. Click Find now - you will see the Printer listed below 6. Select the Printer>Click OK Your printer will be now installed in the second PC. Do the appropriate settings.

Block usb port in windows 2000 server

  Block usb port in windows 2000 server 1. Run Registry Editor (regedit). 2. Navigate to the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor 3. In the right pane, double click on the Start value name. 4. Change the value data to 4 to disable the removable USB mass storage device drive access. 5.To revert and re-enable the drive access for removable USB mass storage device driver, change back the value data for Start to its original default of 3.

how to use idea net setter in linux 10.0 desktop

how to use idea net setter in linux 10.0 desktop plug idea net setter in ubuntu create network connection on the bar set as idea create mobile brodband idea connection open cd rom idea net setter> goto Linux folder> extract file " Mobilepartner.tar.tg" on the desktop after extract files goto driver folder and Ndis driver a file-Ndis install double click on the file and run with terminal then back install file run with terminal then run these files 1.Start mobile partner 2.usb mode through terminol after that goto driver folder and run in terminal mobilepartner then restart your system and login again you enjoy with Idea Net Setter