Skip to main content

Posts

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]!='/')     { ...

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...

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...

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...

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,    le...

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; ...