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

Monday, November 6, 2017

C++ programming language part- 79 Programming Logic and Technique


Programming Logic and Technique:
int a;
display " Type a number";
accept a;
if((a!=0)&&(a%2==0)) display " The number is Even";
else {   if(a==0) {display " The number is Zero "; }
if(a%2!=0) { " The number is Odd ";  }}
Or
if((a!=0)&&(a%2==0)) display " The number is Even";
else {   if(a==0) { display " The number is Zero "; }
else display " The number is Odd "; }
            Or
if((a!=0)&&(a%2==0)) display " The number is Even";
else if(a==0) display" The number is Zero ";
else display " The number is Odd ";
Or
if((a!=0)&&(a%2==0)) display " The number is Even";
else if(a==0) display " The number is Zero ";
else if(a%2!=0) display " The number is Odd ";

Program Ex_9_11
#include
void main()
{
int a;
cout<<" Type a number, please "<
cin>>a;
if((a!=0)&&(a%2==0))
cout<<" The number is Even"<
else
{
            if(a==0)
            {
            cout<<" The number is Zero "<
            }
            if(a%2!=0)
            {
            cout<<" The number is Odd "<
            }
}
}


Program EX_9_12
#include
void main()
{
int a;
cout<<" Type a number, please "<
cin>>a;
if((a!=0)&&(a%2==0))
cout<<" The number is Even"<
else
{
            if(a==0)
            {
            cout<<" The number is Zero "<
            }
            else
            cout<<" The number is Odd "<
}
}


Program Ex_9_13
#include
void main()
{
int a;
cout<<" Type a number, please "<
cin>>a;
if((a!=0)&&(a%2==0))
cout<<" The number is Even"<
else if(a==0)
            cout<<" The number is Zero "<
            else
            cout<<" The number is Odd "<
}


Program Ex_9_14
#include
void main()
{
int a;
cout<<" Type a number, please "<
cin>>a;
if((a!=0)&&(a%2==0))
cout<<" The number is Even"<
else if(a==0)
            cout<<" The number is Zero "<
else if(a%2!=0)
            cout<<" The number is Odd "<
}


Program Ex_9_2
#include
void main()
{
        char type;
            int size;
            cout<<" Type the color of your Television(B/C) ? ";
            cin>>type;
           
        if (type=='B')
            cout<<"You will get 5% discount "<
            else
             cout<<"Color?, type size in inches ";
             cin>>size;
            {
            if(size==14)
            cout<<"You will get 10% discount "<
            else
            cout<<"You will get 15% discount "<
            }
}


Program Ex_9_3
#include
void main()
{
            int p;
            cout<<" Type your year,please "<
            cin>>p;
            if(((p%4==0)&&(p%100!=0))||(p%400==0))
            cout<<"The Year is Leap year"<
            else
            cout<<"The Year is not leap Year";
}



Program Ex_9_4_1
#include
void main()
{
            int p1,p2,p3;
            cout<<" Type first  number, please "<
            cin>>p1;
            cout<<" Type second number, please "<
            cin>>p2;
            cout<<" Type first  number, please "<
            cin>>p3;
            if(p1>p2)
               {
               if(p1>p3)
               cout<<"The largest number is "<
               else
               cout<<"The largest number is "<
               }
            else
        {
               if(p2>p3)
               cout<<"The largest number is "<
               else
               cout<<"The largest number is "<
            }
        }
Alternate

Program 9_4_2
#include
void main()
{
            int p1,p2,p3;
            int high;
            cout<<" Type first  number, please "<
            cin>>p1;
            cout<<" Type second number, please "<
            cin>>p2;
            cout<<" Type first  number, please "<
            cin>>p3;
            if(p1>p2)
            high=p1;
            else
            high=p2;
            if(p3>high)
        cout<<"The largest number is "<
            else
            cout<<"The largest number is "<
}

Program Ex_9_5
#include
void main()
{
            int p1,p2,reminder;
            cout<<" Type first  number, please "<
            cin>>p1;
            cout<<" Type second number, please "<
            cin>>p2;

            if(((p2!=0)&&(p2>0))&&(p2>p1))
            {
            reminder=p1%p2;
            }
            else
            cout<<"Sorry man! ";
}




           

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


Programming Logic and Technique:
{ char string1[10], string2[10];           //array of size 10 defined
               int i,j;
                        display "type a string "
                        accept string1;
              for(i=0;string1[i]!='\0';i++);
                i--;
                        display " The reverse string is ";
              for(j=0;i>=0;j++,i--)
            {
                 string2[j]=string1[i];
            }
                 string2[j]='\0';
                 display<


Program Ex_19_1
            //reverse 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 a string "<<"\n";
            cin>>a1;
            for(i=0;a1[i]!='\0';i++);
                i--;
                        cout<<" The reverse string is "<
            for(j=0;i>=0;j++,i--)
            {
                 a2[j]=a1[i];//
            }
                 a2[j]='\0';
                 cout<

        }



Sunday, November 5, 2017

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


Programming Logic and Technique:
{ char string[10];
               int i,j;
            display "type the  string ";
            accept>> string ;
                        for(i=0;a[i]!='\0';i++);
                        i--;
                        for(j=0;i>=0;j++,i--)
          {
               if(string [j]== string [i])
               continue;
               else
               break;
            }
            if(j>i)
            display" Your string is  Palindrome";
            else
            display " Your string isn't Palindrome";
           
Program Ex_19_2
//palindrome (arraydemo.c)
            #include
            #include
            void main()
            {
            clrscr();   // To clean the screen
            char a[10];//array of size 10 defined
            int i,j;
                        cout<<"type the  string "<<"\n";
            cin>>a;
            for(i=0;a[i]!='\0';i++);
                i--;
            for(j=0;i>=0;j++,i--)
          {
               if(a[j]==a[i])
               continue;
               else
               break;
            }
            if(j>i)
            cout<<" Your string is  Palibdrome"<
            else
        cout<<" Your string isn't Palindrome"<


        }