Você está na página 1de 5

Subject Name : OBC 320 C + + & DBMS Lab

Enrollment Number : A1922214003(el)


Roll Number : A1922214003(el)
Student Name : NAVEEN NAGALINAM
Semester : VI

INSTRUCTIONS

a) All answer script is to be completed as typed in word/pdf.


b) Questions are required to be attempted as mentioned in the Question paper.
c) Answer script is to be completed by due date and need to be submitted for
evaluation by Amity University at addoepractical@amityonline.com
d) Fill this page and attach as the front page of your answer sheet and No answer
sheet would be accepted if this cover page would not be attached with the sheet.
END TERM PRACTICAL EXAMINATIONS, JUNE 2017
BACHELOR of COMPUTER APPLICATION
C++ & DBMS LAB

TIME: 1.00 to 3.00 PM MAX MARKS: 70

Note: Choose one question from each section. 35x2

Section A

Q1. Write a program in C++ to reverse the digit of the given


number.

vim reverse.cpp
#include <iostream>
using namespace std;

int main()
{
int n, revNo = 0, remainder;

cout << "Enter an integer: ";


cin >> n;

while(n != 0)
{
remainder = n%10;
revNo = revNo*10 + remainder;
n /= 10;
}

cout << "Reversed number = " << revNo;

return 0;

}
OUTPUT:

PS C:\Users\Naveen> g++ reverse.cpp -o c

PS C:\Users\Naveen> ./c

Enter an integer: 12345


Reversed number = 54321

Q2. Write a program in C++ for addition of two M*N Matrix.

PS C:\Users\Naveen> vim addmat.cpp


#include<iostream>

using namespace std;

main()
{
int a, b, c, d, mat1[10][10], mat2[10][10], sum[10][10];

cout << "Enter the number of rows and columns of matrix 1";
cin >> a >> b;
cout << "Enter the elements of matrix 1\b";

for ( c = 0 ; c < a ; c++ )


for ( d = 0 ; d < b ; d++ )
cin >> mat1[c][d];

cout << "Enter the elements of matrix 2\b";

for ( c = 0 ; c < a ;c++ )


for ( d = 0 ; d < b ; d++ )
cin >> mat2[c][d];

for ( c = 0 ; c < a ; c++ )


for ( d = 0 ; d < b ; d++ )
sum[c][d] = mat1[c][d] + mat2[c][d];

cout << "Sum of entered matrices:-\b";

for ( c = 0 ; c < a ; c++ )


{
for ( d = 0 ; d < b ; d++ )
cout << sum[c][d] << "\t";

cout << endl;


}

return 0;
}
OUTPUT:

PS C:\Users\Naveen> g++ addmat.cpp

PS C:\Users\Naveen> ./a

Enter the number of rows and columns of matrix 1


Enter the elements of matrix 1

1 2 3 4 5 6 7 8 9 10

Enter the elements of matrix 2

1 2 3 4 5 6 7 8 9 10

Sum of entered matrice

2 4 6 8 10

12 14 16 18 20

Section B:

Q3.

REGD.NO NAME BRANCH


0001 Ram CSE
0002 Hari MECH
0003 Pradeep EEE
0004 Deepak ETC
Write Sql Commands to generate above given Table.

Q4. Perform the following operations in table given in question 3:

I. Add one new column Age in table.

ALTER TABLE STUDENT

ADD AGE INTEGER NOT NULL;

II. Insert new row in table

INSERT INTO STUDENT (REGD.NO, NAME, BRANCH, AGE)

VALUES (005, Pathak, EEE);


III. Change branch name of Hari to EEE.

UPDATE STUDENT

SET BRANCH = EEE

WHERE NAME = HARI;

Você também pode gostar