Skip to main content

Posts

Showing posts from October, 2012

Program that performs selection search in C++ Programming

#include <iostream.h> #include <conio.h> class sel_search { int d[50],s,search_val; public: void getdata(void); int search(void); void display(void); }; void sel_search :: getdata(void) { cout<<endl<<endl; cout<<"How many size of array you want to create:-"; cin>>s; cout<<"Enter "<<s<<" Integers\n"; for(int i=0;i<s;i++)     cin>>d[i]; cout<<"\n\nEnter your search:-"; cin>>search_val; } int  sel_search :: search(void) { for(int i=0;i<s;i++) {     if(d[i]==search_val)            return(i+1); } return(-1); } void sel_search :: display(void) { int result; cout<<"\n\n\n"; result=search(); if(result==-1)     cout<<"\nEntered Search is Illegal\n"; else     cout<<"\nSearch is Located at "<<result<<" Position"; } void main() { clrscr(); sel_search o1; o1.getdat

Program of LL Parser in C++ Programming

#include<iostream.h> #include<stdio.h> #include<conio.h> #include<stdlib.h> #include<string.h> int main()      {        char tmp[15];        char str[15], csf[15]={"E"};        int ssm=0, i, j, v, k, pos=0, a;        clrscr();        char pt[6][5][4]={"" , "i" , "+" , "*" , "/",              "E", "TX", "n" , "n" , "n",              "X", "n" , "TX", "n" , "" ,              "T", "VY", "n" , "n" , "n",              "Y", "n" , ""  , "VY", "" ,              "V", "i" , "n" , "n" , "n"};      cout<<"\n Enter An Expression: "<<endl;      cin>>str;      while(str[ssm]!='/')     {       pos=0;      

Program of Scaner

#include<stdio.h> #include<conio.h> #include<ctype.h> #include<string.h> #include<iostream.h> #include<stdlib.h> int isoperator(char ch)   {     if(ch=='+')         return 1;     elseif(ch=='-')         return 2;     elseif(ch=='*')         return 3;     elseif(ch=='/')         return 4;     elseif(ch=='=')         return 5;     elsereturn 0;   } /*int issymbol(int symcounter,char symbol[][10],char currstr[])   {     for(int i=0;i<symcounter;i++)       {         if(strcmp(symbol[i],currstr)==0)             return i;       }     return -1;   }*/ void main() {     char instr[50];     char currstr[50];     char symbol[10][10];     int scantab[6][5]={ 1, 2, 3,-1,-1,                -1,-1,-1,-1,-1,                -1, 2, 2, 2,-1,                -1,-1, 3,-1, 4,                -1,-1, 5,-1,-1,                -1,-1, 5,-1,-1 };     int counter=0,j;     int currstate=0,symcoun

Program of Scaner

#include<stdio.h> #include<conio.h> #include<ctype.h> #include<string.h> #include<iostream.h> #include<stdlib.h> int isoperator(char ch)   {     if(ch=='+')         return 1;     elseif(ch=='-')         return 2;     elseif(ch=='*')         return 3;     elseif(ch=='/')         return 4;     elseif(ch=='=')         return 5;     elsereturn 0;   } /*int issymbol(int symcounter,char symbol[][10],char currstr[])   {     for(int i=0;i<symcounter;i++)       {         if(strcmp(symbol[i],currstr)==0)             return i;       }     return -1;   }*/ void main() {     char instr[50];     char currstr[50];     char symbol[10][10];     int scantab[6][5]={ 1, 2, 3,-1,-1,                -1,-1,-1,-1,-1,                -1, 2, 2, 2,-1,                -1,-1, 3,-1, 4,                -1,-1, 5,-1,-1,                -1,-1, 5,-1,-1 };     int counter=0,j;     int currstate=0,symcoun

Program of cector class that perform different operations on vector in C++ Programming

#include <iostream.h> #include <conio.h> intconst size=50; class vector { float d[size]; int s; public: void create(void); void modify(void); void multiply(void); void display(void); }; void vector :: create(void) { cout<<"\n\nEnter of Array you want to create:-"; cin>>s; cout<<"Enter "<<s<<" Real Numbers\n"; for(int i=0;i<s;i++)        cin>>d[i]; } void vector :: modify(void) { int mfy_value; float with; cout<<"\nEnter Value is to be modified:-"; cin>>mfy_value; cout<<"Enter Value with which you want to Replace:-"; cin>>with; int search=0; for(int i=0;search<s;i++) {     if(mfy_value==d[i])        {       d[i]=with;       }    search=i+1; } } void vector :: multiply(void) { int mul; cout<<"\nEnter value with which you want to multiply:-"; cin>>mul; for(int i=0;i<s;i++)     d[i]=d[i]*m

Program to Rotate a List n Places to the left

JUST A WAY TO DO IT NOT A REAL PROGRAM Rotate a list N places to the left % rotate(L1,N,L2) :- the list L2 is obtained from the list L1 by %    rotating the elements of L1 N places to the left. %    Examples: %    rotate([a,b,c,d,e,f,g,h],3,[d,e,f,g,h,a,b,c]) %    rotate([a,b,c,d,e,f,g,h],-2,[g,h,a,b,c,d,e,f]) %    (list,integer,list) (+,+,?) % Split a list into two parts % split(L,N,L1,L2) :- the list L1 contains the first N elements %    of the list L, the list L2 contains the remaining elements. %    (list,integer,list,list) (?,+,?,?) domains  list=symbol* predicates  rotate(list,integer,list).  length(list,integer).  rotate_left(list,integer,list).  append(list,list,list).  split(list,integer,list,list). clauses rotate(L1,N,L2) :- N >= 0,    length(L1,NL1), N1 = N mod NL1, rotate_left(L1,N1,L2). rotate(L1,N,L2) :- N < 0,    length(L1,NL1), N1 = NL1 + (N mod NL1), rotate_left(L1,N1,L2). rotate_left(L,0,L). rotate_left(L1,N,L2) :- N > 0, s

Program of virtual piano

//////////////Tested And Created By C++/////////////////////////////// #include<stdio.h> #include<dos.h> #include<conio.h> #include<stdlib.h> #define SHOW 1 #define HIDE 2 union REGS input,output; class piano {  public:int BIGKEY,MIDKEY,back,border;     piano()//init constructor     {         BIGKEY=15;         MIDKEY=1;         back=7;         border=15;     } }color; void drawpiano(int x,int y); int check_xy(int x,int y); void BOX(int c,int r,int c1,int r1,int col); int initmouse(); void setupscreen(); void pointer(int on); void restrictmouse(int x1,int y1,int x2,int y2); void check_keys(int x,int y); void getmouse(int *button,int *x,int *y); float freq[7] = {130.81, 146.83, 164.81, 174.61,196, 220, 246.94 } ; int n=0,a=4,backcolor=2,exitcode=1; void showbar(int t) {  if(t>65) t=65;  if(t<1) t=1;  textcolor(15);  for(int q=0;q<=t;t++)  {     gotoxy(3+q,4);     cprintf("Û");  } } void main() {  int

program is to read text and count all occurrences of a particular word

//////Created And Tested By :-  Rahul Upadhyay ////////////////////// #include<stdio.h> #include<conio.h> #include<string.h> void main() { int i=0,j,count=0; char text[100],word[30],dummy[30]; clrscr(); printf("Enter text:\n"); gets(text); printf("****************************************************"); printf("\nEnter word to search: "); gets(word); printf("----------------------------------------------------"); printf("\nWord occurs at: "); while(i<strlen(text)-1) { j=0; while(text[i]!='\t'&&text[i]!=' ') { dummy[j]=text[i]; j++; i++; if(i==strlen(text)) break; } dummy[j]='\0'; if(strcmp(word,dummy)==0) { printf("%d ",i-strlen(word)); count++; } i++; } if(count==0) printf("NOWHERE"); getch(); }

Program of reflection in y Axis

///////////////Tested And Created By C++////////////////////////// Program Have Got  Errors Can u Correct Do Comment # include <iostream.h> # include <conio.h> # include <graphics.h> # include <math.h> char IncFlag; int PolygonPoints[3][2] =     {{10,100},{110,100},{110,200}}; void PolyLine() {     int iCnt;     cleardevice();     line(0,240,640,240);     line(320,0,320,480);     for (iCnt=0; iCnt<3; iCnt++)     {         line(PolygonPoints[iCnt][0],PolygonPoints[iCnt][1],           PolygonPoints[(iCnt+1)%3][0],PolygonPoints[(iCnt+1)%3][1]);     } } void Reflect() {     float Angle;     int iCnt;     int Tx,Ty;     cout<<endl;     for (iCnt=0; iCnt<3; iCnt++)         PolygonPoints[iCnt][0] = (640 - PolygonPoints[iCnt][0]); } void main() {     int gDriver = DETECT, gMode;     int iCnt;     initgraph(&gDriver, &gMode, "C:\\TC\\BGI");     for (iCnt=0; iCnt<3; iCnt++)     {         PolygonP

Memory Leaks

A certain function that dynamically allocates memory to some object but forgets to deallocate the reserved memory , comsumes some amount of memory every time its is executed. Thus, a part of the memory disappears  with its every run , and eventually the amount of memory consumed has an adverse effect on the system . This situation is known as a memory leak.  MANY POSSIBLE  REASON LEAD TO THE SITUATION OF MEMORY LEAKS  1. Forgetting to DELETE something that has been dynamically allocated ( i.e using new ) 2. Failing to notice that code may bypass a delete statement under certain  circumstances . 3. Assigning the result of a new statement to a pointer that was already pointing to an allocated object

Love or Enemy

/////////////////////////CREATED BY C++ AND TESTED///////////////////////////////// #include<iostream.h> #include<conio.h> #include<string.h> int main() { char n1[20],n2[20],a[20],b[20]; int i,j,k,tot=0; cout<<"\n Enter the boy name  : "; cin>>a; cout<<"\n Enter the girl name : "; cin>>b; cout<<endl; strcpy(n1,a); strcpy(n2,b); i=strlen(a); j=strlen(b); tot=i+j; for(i=0;a[i]!=NULL;i++) { for(j=0;b[j]!=NULL;j++) { if(a[i]==b[j]) { tot=tot-2; b[j]='*'; break; } } } //cout<<"\n count = "<<tot<<endl; if(tot == 2 ||tot== 4 || tot==7 ||tot==9 ) cout<<   n1 << " and " << n2 << " are Enemy"; else if( tot == 3 ||tot==5 || tot==14 ||tot==16 || tot==18 ) cout<<   n1 << " and " << n2 << " are Friends"; else if( tot == 8 || tot==12 || tot==17) cout<<   n1 << &q

Death Date

#include<stdio.h> #include<conio.h> #include<dos.h> #include<string.h> void main() {     int i,j,rbw,dyrq=85,bmid;     void title();     void title1();     char month[3],fo;     char name[25],dmm[3];     char o1,dobmm,smoke;     float height,weight,bmi;     int digit=0,dobdd,dobyy,dobs,ddd,dyy;     void dob(),calc();     clrscr();     printf("\n\n\n\n\n\n                   The Program Will show your death date!!");     delay(1000);     clrscr();     for(i=0; i<=100;i++)     {         clrscr();         title1();         printf(" %d %",i);         printf(" completed");         delay(20);     }     printf("\nPress ANY KEY !! to continue");     getch();     title();     first:     printf("\nAre you ready ?!");     delay(200);     printf("\n!!Press Y/N");     o1=getche();     switch(o1)     {         case 'Y':         case 'y':         goto y;    

Compiler Check

Ever Wondered which compiler you use in C++ or C . There are many compilers from which u can be useing any one of them Here is the list of some Compilers :- So Find Now Which Compiler You Use .

Some High Level Question

Q. Write a program to run a Card Game? Q. write a program which can moniter the Card game Created above? Q. Write a Program which can calculate the money earned or lossed by 1. person on the above card game If You are able to Write all three Program we can guess that u are a Level Programmer ,  You can Post answers To the Comment Box Below or Email At:- Bennymathu09@gmail.com

Starting C++

This video is for the Very People Started C++ Or C. So You installed C++  i mean Turbo C++ 3 or so . Now How to Find it where u installed it , this video Will help  From the Very moment u installed the Turbo C here what u have to do have a look :-

Different Values Of Pointers

Wondered how you can see the Different values of Pointers pointing to array here is a simple program. Program to print different values being pointing to by an array of pointers ////////////////////////////////Tested By C++ and Created//////////////////////////////// #include <iostream.h> #include <conio.h> void main() { clrscr(); int *ip[5];                              ///////Array of 5 int Pionters/// int f=65,s=67,t=69,fo=70,fi=75;          ////// 5 int variables//////// ip[0]=&f;      ip[1]=&s;   ip[2]=&t; ip[3]=&fo;     ip[4]=&fi; for(int i=0;i<5;i++) cout<<"\tThe Program Prints diff. Values pointing by an array\n"; cout<<"\n\nThe pointer ip["<<i<<"]points to "<<*ip[i]<<"\n"; cout<<"The base address stored in the array ip of pointers is "<<ip<<"\n"; for(i=0;i<5;i++) cout<<"The address st