know yourselves. information, computer, 7 wonders, various.

Sunday, November 5, 2017

C++ programming language- part- 85 Programming Logic and Technique:


Ex: 21_2 Compare two string, the string is equal or not.

Programming Logic and Technique:
//compare two strings (arraydemo.c)
            char string1[10],string2[10];//array of size 10 defined
            int i;
            char K=1;
                        cout<<"type first string "<<"\n";
                        cin>>string1;
                        cout<<"type second string "<<"\n";
                        cin>>string2;
            for(i=0;string1[i]!='\0',string2[i]!='\0';i++);
        {
            if(string 1[i]!= string 2[i])
            {
            k=0;
            }
            }
            if(k==0)
            {
            cout<< "those are not equal ";
            }
            else
            {
            cout<<" those are equal ";
            }
            }



Program Ex_21_2
//compare two strings (arraydemo.c)
            #include
            #include
            void main()
            {
            clrscr();   // To clean the screen
            char a1[10],a2[10];//array of size 10 defined
            int i;
        char flag=1;
                        cout<<"type first string "<<"\n";
cin>>a1;
cout<<"type second string "<<"\n";
                        cin>>a2;
            for(i=0;a1[i]!='\0',a2[i]!='\0';i++);
        {
            if(a1[i]!=a2[i])
            {
            flag=0;
            }
            }
            if(flag==0)
            {
            cout<< "those are not equal ";
            }
            else
            {
            cout<<" those are equal ";
            }
            }


Program Ex_21_3

//assign first array to other (arraydemo.c)
            #include
            #include
            void main()
            {
            clrscr();   // To clean the screen
            char a1[5],a2[5];//array of size 5 defined
            int i,j;
                        for(i=0;i<5 i="" o:p="">
                {
                        cout<<"type number/char "<<"\n";
                        cin>>a1[i];
               
            a2[i]=a1[i];
        }
            cout<<" The second array is "<
                //cin>>a2[i];
            for(i=0;i<5 i="" o:p="">
            cout<
            }

Program Ex_21_4

            //palindrome (arraydemo.c)
            #include
            #include
            void main()
            {
            clrscr();   // To clean the screen
            char a1[10],a2[10];//array of size 10 defined
            char a3[20];     // can be char *a3
            int i,j;
            //a3=new char[20];
            cout<<"type the  string "<<"\n";
                        cin>>a1;
                        cout<<"type another string "<<"\n";
                cin>>a2;
            for(i=0;a1[i];i++)
            a3[i]=a1[i];
            for(j=0;a2[j];j++,i++)
            a3[i]=a2[j];
            a3[i]='\0';
            cout<<"The marged string is "<

            }

Alternate
            #include
            void main()
            {
            clrscr();   // To clean the screen
            char a1[10],a2[10];//array of size 10 defined
            int i,j;


            cout<<"type the  string1 "<<"\n";
                        cin>>a1;
                        cout<<"type another string2 "<<"\n";
                cin>>a2;
            for(i=0;a1[i]!='\0';i++);
            for(j=0;a2[j]!='\0';j++,i++)
            {
       a1[i]=a2[j];
        }
            a1[i]='\0';
            cout<<"the content is "<
            }





C++ programming language - Part 86 - assign the content of two string


assign the content of two string
Program Ex_21_5
            //assign the content of two string (arraydemo.c)
            #include
            #include
            void main()
            {
            clrscr();                         // To clean the screen
            char a1[10],a2[10];      //array of size 10 defined
            int i,j;
             
                        cout<<"type string1"<<"\n";
                        cin>>a1;
                        cout<<"type string2"<<"\n";
                        cin>>a2;
            for(i=0,j=0;a1[i]!='\0';i++,j++)
             {
              a1[i]=a2[j];

             }
       
             cout<<"first is changed as " <
            }








Write a program to read two string “ NOVA” & “Dhaka” but prints backward      Suppose Dhaka NOVA.

Program Ex_22_2
#include
void main()
{
char a1[10]; char a2[10]; char a3[10];
int I, j;
cout<<"type string1"<
cin>>a1;
cout<<"type string2"<
cin>>a2;
 
for(I=0;a2[I]!='\0';I++)
a3[I]=a2[I];
for(j=0;a1[j]!='\0';j++,I++)
a3[I]=a2[j];
a3[I]='\0';
cout<<"this is "<

Write a program to compare two stringusing string handle

Program Ex 33_1
//structure.demo
            #include
            #include

           
            void main()
        {
            char str1[20],str2[20];
            int x;
            cout<<"Type string1 "<
            cin>>str1;
        cout<<"Type string2 "<
            cin>>srt2;
            x=strcmp(str1,str2);
            if(x!=0)
            cout<<"not equal "<
            else
            cout<<"equal "<
            }
2. Write a program to marge two stringusing string handle
program Ex 33_2
            //structure.demo
            #include
            #include
            #include
           
            void main()
        {
            char str1[20],str2[20];
            int x;
            cout<<"Type string1 "<
            cin>>str1;
        cout<<"Type string2 "<
            cin>>str2;
            //x=strcat(str1,str2);
       //   if(x!=0)
            //cout<<"not equal "<
            //else
            cout<<"marged =  "<
            }



dynamic pointer


PPPPP Ex 41_1

            //dynamic pointer.demo
           //file output
           #include
            #include
            #include
            class word
            {
              private:
                        char w[20];
              public:

                        void store_word(char *cstr)
                        {
                          strcpy(w,cstr);
                        }
                        void add_word(char *cstr)
                        {
                          strcat(w,cstr);
                        }
                        void display(void)
                        {
                          cout<<" string is "<
                        }

                         
                        word(char *cstr)
                        {
                          strcpy(w,cstr);
                        }
                        word()
                        {
                        strcpy(w,NULL);
                        }
                       
                        ~word()
                        {
                        w[0],'\0';
                        }
                  };

                  void main()
                  {
                  word w1,w2;
                  w2.store_word("Bangladesh");   //
                  w1.display();
                  cout<<"Test line........ "<
                  w2.display();
                  cout<
                  w2.add_word(" & America");     //
                  w2.display();
                  w1.store_word(" China alon");  //
                  cout<
                  w1.display();
                  getch();
                  }




inherit.demo

PPPPP 47_92
ex 7.1

            //inherit.demo
            #include
            #include
            #include
             //Scope resulation with overidden
            class customer             //class defined
            {
          char cname[21];
              int no_people;
              char ccat;
              float fcost;
              char cstart_date[9];


          public:
              void data_in()
               {
           cout<<"Type name \t";
               cin>>cname;
               cout<<" Type number of people \t";
               cin>>no_people;
               cout<<"Type catagory(N/S) \t";     // Normal or Special
               cin>>ccat;
               cout<<"Type the cost \t";
               cin>>fcost;
               cout<<"Type start date \t";
           cin>>cstart_date;
               }

              void data_out()
               {
               cout<<"name is= "<
               cout<<"No of people are = "<
           cout<<"catagory is = "<
           cout<<"cost is = "<
               cout<<"start date is = "<
               }
             };


             void main()
             {
             char choice;
             customer c1;
             do
             {
             cout<<"\n1: Query  2:Accept    3: Display   4: Exit ";
             cout<<"\n\nType choice: ";
             cin>>choice;
             if(choice=='1')
             {
            fstream fill("customer.txt",ios::in); //ios::app
                        int pos,n;
                        cout<
                        cin>>n;
                        pos=(sizeof(customer))*(n-1);
                        fill.seekg(pos,ios::beg);
                        fill.read((char*)&c1,sizeof(c1));  //type cast
                        c1.data_out();
                        fill.close();
                        getch();
             }
             else if(choice=='2')
             {
                        fstream fill("customer.txt",ios::app);
                        c1.data_in();
                        fill.write((char*)&c1, sizeof(c1));  // type cast
                        fill.close();
             }
             else if(choice=='3')
             {
                        fstream fill("customer.txt",ios::in);
                        fill.read((char*)&c1,sizeof(c1));
                        while(fill)
                                    {
                                    c1.data_out();
                                    fill.read((char*)&c1,sizeof(c1));
                                    getch();
                                    }
                        fill.close();
             }
             }while(choice!='4');
             }




Thursday, March 23, 2017

Learn Computer






Subject: MS-Word, MS-Excel, MS-Access, MS-PowerPoint and Internet Concept
Class Time : 10.30-12.00 am, 12.00-1.30 pm, 1.30-300pm, 3.00-4.30 pm, 4.30-6.00pm, 6.00-7.30 pm
Total duration 2 months, Class 3 days/week (alternative day).
So come on Hurry……




Nova Computer, 50 Aziz Supar Market (1st Fl.), Shahabagh, Dhaka Ph. 017167171716, 01534657999, 01970667096, (Friday Open)
কম্পিউটার বইয়ের জনপ্রিয় লেখক বাপ্পি আশরাফ সরাসরি তত্ত্বাবধান করেন