Enable contrast version

Tutor profile: Vijay K.

Inactive
Vijay K.
Software Engineer at CGI
Tutor Satisfaction Guarantee

Questions

Subject: Java Programming

TutorMe
Question:

Write a Java Program to swap two numbers with using the third variable.

Inactive
Vijay K.
Answer:

class SwapTwoNumberWithoutThirdVariable { public static void main(String args[]) { int x, y; System.out.println("Enter x and y"); Scanner in = new Scanner(System.in); x = in.nextInt(); y = in.nextInt(); System.out.println("Before Swapping\nx = "+x+"\ny = "+y); x = x + y; y = x - y; x = x - y; System.out.println("After Swapping without third variable\nx = "+x+"\ny = "+y); } }

Subject: Databases

TutorMe
Question:

What are deletion constraints in DBMS. Explain each.

Inactive
Vijay K.
Answer:

Constraints for Deletion of Data: Constraints enforce limits to the data or type of data that can be deleted from a table. The whole purpose of constraints is to maintain the data integrity during a delete into a table. Various types of constraints are listed below. Types of constraints NOT NULL UNIQUE DEFAULT CHECK Key Constraints – PRIMARY KEY, FOREIGN KEY Domain constraints NOT NULL: NOT NULL constraint makes sure that a column does not hold NULL value. When we don’t provide value for a particular column while inserting a record into a table, it takes NULL value by default. By specifying NULL constraint, we can be sure that a particular column(s) cannot have NULL values. Example: CREATE TABLE STUDENT( ROLL_NO INT NOT NULL, STU_NAME VARCHAR (35) NOT NULL, STU_AGE INT NOT NULL, STU_ADDRESS VARCHAR (235), PRIMARY KEY (ROLL_NO) ); UNIQUE: UNIQUE Constraint enforces a column or set of columns to have unique values. If a column has a unique constraint, it means that particular column cannot have duplicate values in a table. CREATE TABLE STUDENT( ROLL_NO INT NOT NULL, STU_NAME VARCHAR (35) NOT NULL UNIQUE, STU_AGE INT NOT NULL, STU_ADDRESS VARCHAR (35) UNIQUE, PRIMARY KEY (ROLL_NO) ); DEFAULT: The DEFAULT constraint provides a default value to a column when there is no value provided while inserting a record into a table. CREATE TABLE STUDENT( ROLL_NO INT NOT NULL, STU_NAME VARCHAR (35) NOT NULL, STU_AGE INT NOT NULL, EXAM_FEE INT DEFAULT 10000, STU_ADDRESS VARCHAR (35) , PRIMARY KEY (ROLL_NO) ); CHECK: This constraint is used for specifying range of values for a particular column of a table. When this constraint is being set on a column, it ensures that the specified column must have the value falling in the specified range. CREATE TABLE STUDENT( ROLL_NO INT NOT NULL CHECK(ROLL_NO >1000) , STU_NAME VARCHAR (35) NOT NULL, STU_AGE INT NOT NULL, EXAM_FEE INT DEFAULT 10000, STU_ADDRESS VARCHAR (35) , PRIMARY KEY (ROLL_NO) ); In the above example we set the check constraint on ROLL_NO column of STUDENT table. Now, the ROLL_NO field must have the value greater than 1000. Key constraints: PRIMARY KEY: Primary key uniquely identifies each record in a table. It must have unique values and cannot contain nulls. In the below example the ROLL_NO field is marked as primary key, that means the ROLL_NO field cannot have duplicate and null values. CREATE TABLE STUDENT( ROLL_NO INT NOT NULL, STU_NAME VARCHAR (35) NOT NULL UNIQUE, STU_AGE INT NOT NULL, STU_ADDRESS VARCHAR (35) UNIQUE, PRIMARY KEY (ROLL_NO) ); FOREIGN KEY: Foreign keys are the columns of a table that points to the primary key of another table. They act as a cross-reference between tables. Domain constraints: Each table has certain set of columns and each column allows a same type of data, based on its data type. The column does not accept values of any other data type. Domain constraints are user defined data type and we can define them like this: Domain Constraint = data type + Constraints (NOT NULL / UNIQUE / PRIMARY KEY / FOREIGN KEY / CHECK / DEFAULT)

Subject: C Programming

TutorMe
Question:

Finding factorial of a program in c using recursion.

Inactive
Vijay K.
Answer:

#include <stdio.h> long int multiplyNumbers(int n); int main() { int n; printf("Enter a positive integer: "); scanf("%d", &n); printf("Factorial of %d = %ld", n, multiplyNumbers(n)); return 0; } long int multiplyNumbers(int n) { if (n >= 1) return n*multiplyNumbers(n-1); else return 1; }

Contact tutor

Send a message explaining your
needs and Vijay will reply soon.
Contact Vijay

Request lesson

Ready now? Request a lesson.
Start Lesson

FAQs

What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Lesson" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.