Friday, 19 June 2015

Learn php in 30 minutes.

The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications. This tutorial helps you to build your base with PHP.


In this video tutorial you can learn pretty much the whole PHP programming language in one video. 
you can get quotes, comments, date(), variables, data types, getting data from HTML, heredoc, constants, arithmetic, shortcuts, reference operators, comparison operators, if, elseif, else, echo, printf, ternary operator, switch, while, for, foreach, arrays, strings, and much more.
 if you want to get more information click here

Thursday, 11 June 2015

2640012 - WTAD - May-June 2011

Gujarat Technological University
Practical Examination – May-June 2011
MCA Semester – IV
Subject Code: 640012 Subject Name: Programming skills-VII (WTAD)

Sr. No
Definition

1
Write a javascript code to make a calculator.

2
A. Write a javascript code using arrays and generate the current date in words, this should include the day, the month and the year. (e.g. Monday, May 16,2011).
B. Write a javascript to build a marquee (a scrolling text box) in JavaScript and HTML.

3
Develop a windows database application to perform the database operations like record Navigation, insert, delete and search on Student table having following details.
Database: Oracle 
Table: Stud_Info
      Field Name     Field Type
      Stud_id            Integer
Stud_name      varchar
Stud_city         varchar
Stud_phone     Numeric
Stud_std          Numeric
Stud_div          varchar
Stud_gender    varchar
             Stud_bod        date

4
Develop a JSP file which will accept the user input e.g Personal Info, Education etc. and display the same content in MS Excel file.

5
Write a Servlet to display all the attributes available from httprequest and servlet context.

6
Develop a servlet application for the interest calculation. Consider few dummy rules for Income tax calculation
If salary < 1,00,000 PA      tax =0
If salary > 100000 and < 2,00,000 then tax =10%
If salary is > 2,00,000 PA the 10% on amount less than 2,00,000 and 15 % on amt above 2,00,000
For female employees provide tax reduction of 4% in all above tax rates.
Prepare a file on server which takes care of this rule. Given salary and gender from the client side, return the actual amount of tax to be paid.
7
Create a web page which displays a list of different items. Create another page using servlet which will display all the selected items by the user. Users may navigate back and forth to select different items and view all items selected by him.

8
Develop a beans application having property named Stu_ID, Stu_Program.  Use 
<jsp:useBean> standard action to set and get the beans propertywith Application scope.

9
Develop a web application in JSP with insert, delete and update operations.
Database: Oracle
Table: Product Info.
Field Name    
Prod_id
Prod_name        i.e Model Name or number
Prod_category           
             Prod_price

10
Develop an index.jsp page to import external text file (test.txt) in it using standard tag library of JSTL.

2640012 - WTAD - Jun, 2013

Gujarat Technological University

MCA Semester-4, Practical Examination – Jun, 2013

Programming Skills – VII (WTAD) [640012]

Max: 80 Marks                                                                Duration: 2.5 Hrs


1.      Create a Servlet which gets Text, Font Color and Background Color from user. Change the background color of the form as per color passed by user. Convert the text in uppercase, make it bold and print it with font color passed by user.


2.      Create a Login Servlet which accepts Username and Password from User. Store it in form of Cookie/Session. If Cookie/Session with same values exists then display message “Successful Login” and if Not then display message “Values are Saved Successfully!”


3.      Using a JSP page, get some number say N from user. Generate N random numbers. From those random numbers display Prime Numbers in form of Ordered List and Non-Prime Numbers in form of Unordered List.


4.      Create an application using JSP Bean: Accepts Book Details like Book Id, Book Name, Author Name, Publisher and Price from user. Store it in a JSP Bean & display it on “book details” page. In a separate page get just Book ID and New Price from User. Update Bean to store new Price for the Book. Display these new details on the same “book details” page.


5.      Create an application using JSP Bean: Get details like First Name, Last Name, Email, Age from user and store it in a JSP Bean. If Age of user is more than 15 years then Display All the Details on “profile.jsp” with Green Background otherwise Display Error Message “Not Authorized to View this Page” on “prof ile.jsp” page with Red Background.



6.      Using MVC Architecture create following application: Store Item Details Item Code, Item Name and Price in any static form or in database. Get Item Code and Quantity from user; match it with list of existing Items. If Item found in the list then display complete Bill in well formatted manner. Otherwise display Error Message “Item Not Found!”


7.      Create application which accepts user details like Firstname, Lastname, Email, Date Of Birth, City, State, Country. Store all the details in database. Create one Report which displays list of all the users stored. Also give links Edit/Delete along with each record which allows user to Edit/Delete that particular record.


8.      Create Custom JSTL Tag which accepts two numbers from user & operation and displays

the appropriate result.

For example: <custom:operation val1=”20” val2=”10” op=”*” /> should display Ans:200 and <custom:operation val1=”20” val2=”10” op=”-” /> should display Ans: 10


9.      Write a Servlet that displays the values of the FirstName, LastName, and EmailAddress request parameters. But, remember what users told you in the past, and use the old values if the current values are missing. So, if a parameter is missing and the client is a first-time visitor, have the servlet list “Unknown” for the mi ssing values. If a parameter is missing and the client is a repeat visitor, have the Servlet use previously entered values for the missing values.


10.  Write a JSP Program to get Employee information through a HTML and create a Java Bean Class, populate Bean and display the same information through another JSP.

    11.  Design a servlet that returns the details of the country like: its capital city, population and the national language of the country sent as a request. Maintain the database for the details of the country.

12.  Develop an MVC application that takes a string from user. Convert the string into uppercase and return to the user. Also append the current time in response. As per the time greet the user. 

2640012 - WTAD - June 2012

Gujarat Technological University
Practical Examination – May-June 2011
MCA Semester – IV
Subject Code: 640012 Subject Name: Programming skills-VII (WTAD)

Sr. No
Definition

1
Write a javascript code to make a calculator.

2
A. Write a javascript code using arrays and generate the current date in words, this should include the day, the month and the year. (e.g. Monday, May 16,2011).
B. Write a javascript to build a marquee (a scrolling text box) in JavaScript and HTML.

3
Develop a windows database application to perform the database operations like record Navigation, insert, delete and search on Student table having following details.
Database: Oracle 
Table: Stud_Info
      Field Name     Field Type
      Stud_id            Integer
Stud_name      varchar
Stud_city         varchar
Stud_phone     Numeric
Stud_std          Numeric
Stud_div          varchar
Stud_gender    varchar
             Stud_bod        date

4
Develop a JSP file which will accept the user input e.g Personal Info, Education etc. and display the same content in MS Excel file.

5
Write a Servlet to display all the attributes available from httprequest and servlet context.

6
Develop a servlet application for the interest calculation. Consider few dummy rules for Income tax calculation
If salary < 1,00,000 PA      tax =0
If salary > 100000 and < 2,00,000 then tax =10%
If salary is > 2,00,000 PA the 10% on amount less than 2,00,000 and 15 % on amt above 2,00,000
For female employees provide tax reduction of 4% in all above tax rates.
Prepare a file on server which takes care of this rule. Given salary and gender from the client side, return the actual amount of tax to be paid.
7
Create a web page which displays a list of different items. Create another page using servlet which will display all the selected items by the user. Users may navigate back and forth to select different items and view all items selected by him.

8
Develop a beans application having property named Stu_ID, Stu_Program.  Use 
<jsp:useBean> standard action to set and get the beans property with Application scope.

9
Develop a web application in JSP with insert, delete and update operations.
Database: Oracle
Table: Product Info.
Field Name    
Prod_id
Prod_name        i.e Model Name or number
Prod_category           
             Prod_price

10
Develop an index.jsp page to import external text file (test.txt) in it using standard tag library of JSTL.


Sunday, 28 August 2011

Question Bank of C



Qu 20. Write a shortcut keys of C


1. Alt + F  -  open file


2. Alt + F + N  -  new file


3. Alt + F9  -  compile programme


4. Ctrl + F9  - execute a program


5. Ctrl + F5  - out put screen


6. F6  - to change between programme screen and error screen


7. F2  -  save programme


8. Alt + ENTER  -  full screen mode


9. Alt + F + L  -  to check programme load or not


10. F3  -  load programme


11. Alt + X  -  exit turbo c

Qu 19. What is important of Comment line in C

All programming languages let you include comments in your programs. Comments can be used to remind yourself (and others) of what processing is taking place or what a particular variable is being used for. They can be used to explain or clarify any aspect of a program which may be difficult to understand by just reading the programming statements. 

This is very important since the easier it is to understand a program, the more confidence you will have that it is correct. It is worth adding anything which makes a program easier to understand.

Remember that a comment (or lack of it) has absolutely no effect on how the program runs. If you remove all the comments from a program, it will run exactly the same way as with the comments.

Each language has its own way of specifying how a comment must be written. In C, we write a comment by enclosing it within /* and */, for example:
/* This program prints a greeting */

A comment extends from /* to the next */ and may span one or more lines. The following is a valid comment:
/* This program reads characters one at a time
and counts the number of letters found */
C also lets you use // to write one-line comments. The comment extends from // to the end of the line, for example:
a = s * s; //calculate area; store in a
In this series, we will use mainly one-line comments.

Qu 18. what is token in c? Explain all type of tokens avalible in C

 In a C source program, the basic element recognized by the compiler is the "token." A token is source-program text that the compiler does not break down into component elements.

Syntax

token:
    keyword

identifier constant string-literal operator punctuator

The keywords, identifiers, constants, string literals, and operators described in this section are examples of tokens. Punctuation characters such as brackets ([ ]), braces ({ }), parentheses ( ( ) ), and commas (,) are also tokens.


C token is an individual word present in the c-language. There are 6 types
  • Keywords: keywords are defined by the software with the specified meaning. 
  • In c language 32 keywords are there
                          Example: double,int,struct, etc
  • Identifiers:User defined variable names.
  • Constants: The value which is not changed during the execution
  • Strings: Group of caharacters enclosed in " "
  • Operators: The following are the operators available in c
  • 1.Arthematic Operators: [+,-,*,/,%] 
    2.Assignment Operators: [=] 
    3.Relational Operators: [<,<=,>,>=,==,!=] 
    4.Logical Operators: [and,or,not] 
    5.increment/decrement Operators:[++,--] 
    6.Bitwise Operators: [&,|,~,^,>>,<<] 
    7.Conditional or terinary Operator:[?:]
  • Special characters: ,(comma) -to seperate 
  • 2 variables sizeof Operators -returns the size of the variable

Qu 17. What is backslash in c?

The backslash is a trigger. It says the next character is special. \n is new line, \t is tab, \b is backspace. So logically, the backslash alone can't be used to display a backslash, so you use \\ to display one backslash. 
Backslash Commands 

When used in a character or string expression, the backslash character (\) is used to
give instructions to cout.   For example, \n has the identical effect of endl.      For example:

cout << “This is on one line.” << ‘\n’ << “This is on another line.”;

will produce the output

                         This is on one line.
                         This is on another line

The only advantage of \n is that it can be included in a string.      For example:

                 cout << “This is on one line.\nThis is on another line.”;

will also produce the output

                         This is on one line.
                         This is on another line 

Qu 16. what is trigraph in c

In the C family of programming languages, a trigraph is a sequence of three characters, the first two of which are both question marks, that represents a single character.

The reason for their existence is that the basic character set of C (a subset of the ASCII character set) includes nine characters which lie outside the ISO 646 invariant character set. This can pose a problem for writing source code when the keyboard being used does not support any of these nine characters. The ANSI C committee invented trigraphs as a way of entering source code using keyboards that support any version of the ISO 646 character set.

Trigraphs might also be used for some EBCDIC code pages that lack characters such as { and }.

Trigraphs are not commonly encountered outside compiler test suites. Some compilers support an option to turn recognition of trigraphs off, or disable trigraphs by default and require an option to turn them on. Some can issue warnings when they encounter trigraphs in source files. Borland supplied a separate program, the trigraph preprocessor, to be used only when trigraph processing is desired (the rationale was to maximise speed of compilation).

The C preprocessor replaces all occurrences of the following nine trigraph sequences by their single-character equivalents before any other processing.
Trigraph Equivalent
??= #
??/ \
??' ^
??( [
??) ]
??! |
??< {
??> }
??- ~

Note that ??? is not a trigraph sequence.

Note also that the problematic characters are nevertheless required to exist within the implementation, in both the source and execution character sets.

Qu 15. Write Syntax and Example of printf and scanf.

1. printf

The printf function is the main method used for outputting text in C programs. printf is a library function contained in the stdio library. The general form of printf is shown below.
Syntax: printf ( <format string>, arg1, arg2, arg3, ... ) ;
The format string can contain text, control characters and also markers that indicate where the value of a variable should be displayed within the output text. Following the format string are a list of variables (or constants) that should be output as part of the message. These variables are separated with commas. For each variable marker in the format string, there should be a corresponding variable included in the argument list. The following examples will show how printf is used.

Display text:
                printf("Hello World!");
Display text and move to the next line:
                printf("Hello World!\n");

The character sequence \n indicates that you should move to the next line. If this is not included, the next printf will print on the same line as this one. The newline character \n is a single character. It is not possible to enter the character directly. The \ indicates that you are specifying a special character, and the following letter, an n in this case, specifies which special character.
Display text and the value of an integer:

                printf("We have been in school %d days.\n", dayCount); 
/*dayCount is a variable*/

The %d in the format string indicates that the printf command should insert the value of the first variable in the argument list, in this case, the value dayCount.

A constant can be used instead of a variable:
                printf("We have been in school %d days.\n", 23);

This constant could also be put directly in the format string instead of the %d.
Different control charactes correspond to different variable types. The %d character can be used with integer variables. Control characters for the various data types are shown in the table below.
int %d float %f double %lf string %s single character %c a format string may reference several variables. Example statements and their output are shown in the sample code below.


#include <stdio.h>
int main(int argc, char* argv[])
{
    int count = 9;
    float fract = 3.5;
    double percent = 37.6389;
    char singleChar = 'A';
    char * testString = "happy";
    printf("The student's average was: %lf\n", percent);
    /*Output:  The student's average was: 37.638900;*/
    printf("A fraction %f, a string %s and a character %c\n", fract,testString, singleChar);
    /*Output:  A fraction 3.500000, a string happy and a character A*/
    printf("Numbers without spaces %d%lf%f", count, percent, fract);
    /*Output:  Numbers without spaces 937.6389003.500000;*/
    getch();
}

2. scanf
The command scanf can be used in C programs to input data. scanf has similar syntax to printf. The general form is shown below.
                scanf ( <format string>, arg1, arg2, arg3, ... ) ;
With scanf, the format string specifies the type of data the program is expecting to get from the user. The list of arguments are the variables where the data should be stored. printf and scanf use the same control characters for the various variable types.
scanf will store the data it receives in the memory location where the variable is stored. In order to do this, it needs the memory location of the variable. Preceding the variable name with an & indicates the address of the variable, rather than the variable itself. For instance, the following command will read an integer and store it in the variable index.
int index;
    scanf("%d", &index);
The sample code below shows various examples of scanf usage.
#include <stdio.h>
int main(int argc, char* argv[])
{
    int sample;
    float fl;
    char string[33]; /*string that will hold 32 characters plus the termination character*/
    printf("Type an integer: \n");
    scanf("%d", &sample);
    printf("Type a string: \n");
    scanf("%s", string);
    printf("Type a float: \n");
    scanf("%f", &fl);
    printf("You typed the integer %d, the string %s, the float %f\n", sample, string, fl);
    /*you can also capture multiple values with one scanf*/
    /*scanf returns the number of values it receives, so a
                  program can check to make sure all the desired data was
                  received*/
    int dataReceived = 0;
    int testInt;
    float testFloat;
    printf("Enter an int and a float separated by a space\n");
    dataReceived = scanf("%d %f", &testInt, &testFloat);
    printf ("Scanf received %d items of data.  You entered the int %d and the float %f .\n", dataReceived, testInt, testFloat);
    getch();
}
Output:
Type an integer:
45
Type a string:
happy23
Type a float:
6.879
You typed the integer 45, the string happy23, the float 6.879000
Enter an int and a float separated by a space
51 1.235
Scanf received 2 items of data.  You entered the int 51 and the float 1.235000 .


Qu 14. Explain The #define Directive

The #define Directive
When you compile a program the compiler first uses a preprocessor to analyze the code. The #define directive can be used to either define a constant number or function or to replace an instruction in your code. For instance:

#define for_ever_do while(1)
This means you can use for_ever_do instead of while(1) and the effect will be the same because the preprocessor first replaces for_ever_do with while(1) and then the program is compiled. With #define you can also create function or more precisely called, a macro. Here's another example:

#define sqr(x) (x*x)
When you call sqr(6), the preprocessor will first replace sqr(6) with (6*6) and then compile the program. Another thing that you can do with #define is concatanate two variables. For example:

#define conc(a,b)
int main() {
int xyz=123,try=125;
cout<<conc(xy,z)<<" "<<conc(t,ry);
}
This will display 123 125 because the preprocessor replaces conc(xy,z) with xyz and then evaluates it.

Qu 13. Explain #include directive.

The #include directive tells the preprocessor to treat the contents of a specified file as if those contents had appeared in the source program at the point where the directive appears. 

You can organize constant and macro definitions into include files and then use #include directives to add these definitions to any source file. Include files are also useful for incorporating declarations of external variables and complex data types. You need to define and name the types only once in an include file created for that purpose.


#include  "path-spec"
#include  <path-spec>

The path-spec is a filename optionally preceded by a directory specification. The filename must name an existing file. The syntax of the path-spec depends on the operating system on which the program is compiled.
Both syntax forms cause replacement of that directive by the entire contents of the specified include file. The difference between the two forms is the order in which the preprocessor searches for header files when the path is incompletely specified.



Syntax Form Action
Quoted form This form instructs the preprocessor to look for include files in the same directory of the file that contains the #include statement, and then in the directories of any files that include (#include) that file. The preprocessor then searches along the path specified by the /I compiler option, then along paths specified by the INCLUDE environment variable.
Example #include "defs.h"
 
 
 






Angle-bracket form This form instructs the preprocessor to search for include files first along the path specified by the /I compiler option, then, when compiling from the command line, along the path specified by the INCLUDE environment variable.
Example #include <stdio.h>

Qu 12. What is variable? Explain rules how to declair and intilisation a variable

Variable

A variable is a named memory, that can be used to read and write information. In this sense, variables are nothing more than "buckets" that can be used to store whatever values are needed for a specific computation. However, as different materials require different containers, we also have different types of variables for the various contents that can be stored in it.



Declare Variable initialization

There are two C Standards documents. The original (ANSI-89/ISO-90) did not allow mixed declarations and (executable) code within a block. In fact declarations can occur at the beginning of any block (that is, after the opening { brace and before any code), not just at the beginning of a function. This has been true of all releases of any serious compilers, even before the first standard. This standard is sometimes called C89, and sometimes it's called C90.

CPP / C++ / C Code:
#include <stdio.h>
int main()
{
    int i = 1;
    printf("i = %d\n", i);
    {
        int j = 2;
        printf("i = %d, j = %d\n", i, j);
    }
    return 0;
}

Output:
Code:
i = 1 i = 1, j = 2

The variable j is only visible inside the block in which it is declared. This behavior was also carried forward into C++, so the above program is legal C and C++ for all compilers that I have tested (and all C and C++ compilers should work with that code).

There is a second standard, ISO-99, which allows declarations just about anywhere in a block. (This is commonly called the C99 Standard.)

Many commonly used compilers (Borland and Microsoft to name two with I am familiar) do not allow the mixed declarations of the ISO-99 standard.

So the following would not work with these C compilers, but it would be OK with GNU gcc:
CPP / C++ / C Code:
#include <stdio.h>
int main()
{
    int i = 99;
    printf("i = %d\n", i);
    int j = 42;
    printf("j = %d\n", j);
    return 0;
}
 Rules

• Variable name may be a combination of alphabets, digits or underscores.
 
• Sometimes, compilers in which case its length should not exceed 8 characters impose an additional constraint on the number of characters in the name.
 
• First character must b e alphabet or an underscore.
 
• No. comma or blank space is allowed.
 
• Among the special symbols, only underscore can be used in variable name.
 
• No word, having a reserved meaning in C can be used for variable name.