Friday, 24 June 2016

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";
            }
        }
    }
}

C++ Program - Fibonacci Series

#include
using namespace std;
int main() {
    int i,sum,limit,number1=0,number2=1;
cout<<"Enter limit No. ";
    cin>>limit;
    for(i=0;i<=limit;i++){
cout< sum=number1+number2;
number1=number2;
number2=sum;
}
    return 0;
}

C++ Program - To find Factorial

#include
#include
#include
using namespace std;
int main() {
int num,factorial=1;
cout<<" Enter Number To Find Its Factorial:  ";
    cin>>num;
    for(int i=1;i<=num;i++) {
        factorial=factorial*i;

    }
cout<<"Factorial of Given Number is ="< return 0;
}

C++ Program - Diamond Pattern

#include
using namespace std;
int power(int, int);
int main() {
  int i,j,k,limit;
  cout<<"Enter Number :";
cin>>limit;
    for(int i=1; i<=limit; i++) {
    for(int k=0; k  cout<<" ";
  for(int j=0; j  cout<<"*"<<" ";
}
cout< }
for(int i=limit-1; i>0; i--) {
for(int k=i; k  cout<<" ";
  for(int j=0; j  cout<<"*"<<" ";
}
cout< }
  return 0;  
}

C++ Program - To Check whether Armstrong Number or Not

#include
using namespace std;
int power(int, int);
int main() {
  int armstrong=0,remainder=0,num=0,result=0,check,number;
  cout<<"Enter Number to find it is an Armstrong number?";
cin>>num;
    check=num;
number=num;
    int digits = 0;
    if (number < 0) {
    digits = 1;
}
    while (number) {
        number /= 10;
        digits++;
    }
    for(int i=1;num!=0;i++){
        remainder=num%10;
        num=num/10;
        armstrong=armstrong+power(remainder,digits);
    }
    if(armstrong==check) {
    cout<    } else {
        cout<    }
    return 0;
}
int power(int remainderVal, int digit) {
  int i, multiplyVal = 1;
  for (i = 1; i <= digit; i++)
      multiplyVal = multiplyVal*remainderVal;
  return multiplyVal;  
}

Reduce Array Content C++

#include
#include
#include
using namespace std;
int main() {
char s[5];
cout<<"Please Enter Any 5 Characters:";
cin>>s;
int k=sizeof(s);
int i,j;
for(i=0;i for(j=i;j cout< }
cout<<"\n";
}
return 0;
}

Tuesday, 14 April 2015

Compiling the Program

To compile the Example program, execute the compiler, javac, specifying the name of the source file on the command line, as shown here:

javac Example.java

The javac compiler creates a file called Example.class that contains the bytecode version of the program. Remember, bytecode is not executable code. Bytecode must be executed by a Java Virtual Machine. Thus, the output of javac is not code that can be directly executed. 

To actually run the program, you must use the Java interpreter, java. To do so, pass the class name
Example  as a command-line argument, as shown here: 

java Example

When the program is run, the following output is displayed: Java drives the Web. When Java source code is compiled, each individual class is put into its own output file named after the class and using the .class extension. This is why it is a good idea to give your Java source files the same name as the class they contain—the name of the source file will match the name of the .class
file. When you execute the Java interpreter as just shown, you are actually specifying the name of the class that you want the interpreter to execute. It will automatically search for a file by that name that has the .class extension. If it finds the file, it will execute the code contained in the specified class.

CakePHP Date Picker

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