Friday, 24 June 2016

C++ Program - Swapping Two Integers

#include
using namespace std;
int main() {
    int number1,number2;
cout<<"Enter 1st No. ";
    cin>>number1;
cout<<"Enter 2nd NO ";
    cin>>number2;
    cout<<"Before Swapping ";
cout< number1 = number1 + number2;
number2 = number1 - number2;
number1 = number1 - number2;
cout<<"After Swapping ";
cout<    return 0;
}

C++ Program - To find Prime Number or Not

#include
using namespace std;
int main() {
    int number,count=0;
cout<<"Enter a NO. to check Prime or Not ";
    cin>>number;
    for(int a=2;a<=number/2;a++) {
        if(number%a==0) {
            count++;
            break;
        }
    }
    if(count==0) {
        cout<    } else {
        cout<    }
    return 0;
}

C++ Program - To find Leap Year or Not

#include
using namespace std;
int main() {
    int year;
    cout << "Enter a year: ";
    cin >> year;
    if (year%4 == 0) {
        if (year%100 == 0) {
            if (year%400 == 0) {
                cout << year << " is a leap year.";
            } else {
                cout << year << " is not a leap year.";
            }
        } else {
            cout << year << " is a leap year.";
        }
    } else {
        cout << year << " is not a leap year.";
    }
    return 0;
}




C++ Program - Largest Number in an Array

#include
#include
#include
using namespace std;
int main() {
int i,j,temp,arrSize;
cout<<"Enter Array Size.:";
cin>>arrSize;
int a[arrSize];
cout<<"Enter Any"< for(i=0;i cin>>a[i];
}
for(i=0;i for(j=i+1;j if(a[j] < a[i]) {
temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
}
cout<<"Largest No. is "< return 0;
}

C++ Program - Hollow Square Number Pattern

#include
using namespace std;
main() {
    int squareWidth,limit,tempWidth = 0,i;
cout<< "Enter Widht:   ";
    cin>>  squareWidth;
    limit = (squareWidth-1)*4;
    limit++;
  for(int width=1; width<=squareWidth; width++) {
    if(width <= 1)
    for(i=1; i<=squareWidth; i++) {
    tempWidth++;
                cout<< tempWidth<<"\t";
            }
        else if(width            cout<< endl;
for(i=1; i<=squareWidth; i++) {
      if(i==1 || i==squareWidth)
      if(i == 1) {
  limit--;
                    cout< }
                    if(i == squareWidth) {
                    tempWidth++;
                    cout< }
                else
                    cout<<"\t";
            }
        } else {
            cout<< endl;
for(i=limit-1; i>tempWidth; i--) {
                cout<< i<<"\t";
            }
        }
    }
}

CakePHP Date Picker

Folder Structure: Controller:   File location - cakephp/src/controller/HomepageController.php namespace App\Controller; use...