Diploma Computer/IT

Object Oriented Programming Practical 6

Object Oriented Programming Practical 6 Question 1 Write a C++ program to calculate area of Rectangle using Inline function. rectangle.cpp C #include <iostream.h> #include <conio.h> inline int calculateArea(int length, int width) { return length * width; } void main() { int length, width; cout << "Enter the length of the rectangle: "; cin >> length; […]

Object Oriented Programming Practical 6 Read More »

Object Oriented Programming Practical 5

Object Oriented Programming Practical 5 Question 1 Write a program to find area of circle such that the class circle must have three functions namely:a)read() to accept the radius from user.b)compute() for calculating the areac)display() for displaying the result.(Use Scope resolution operator) circle.cpp C #include<iostream.h> #include<stdio.h> #include<conio.h> class circle { public: int radius; float area;

Object Oriented Programming Practical 5 Read More »

Object Oriented Programming Practical 4

Object Oriented Programming Practical 4 Question 1 Define a class Room with data members length, breadth and height. Member function calculate_area () and calculate_volume(). Calculate the area and volume of room. Define the member function inside the class. room.cpp C #include<iostream.h> #include<stdio.h> #include<conio.h> class room { public: int length,breadth,height; void accept() { cout<<"nEnter length of

Object Oriented Programming Practical 4 Read More »

Object Oriented Programming Practical 3

Object Oriented Programming Practical 3 Question 1 Calculate average of two numbers using explicit type casting average.cpp C #include<iostream.h> #include<conio.h> void main() { int num1, num2; float average; cout << "Enter the first number: "; cin >> num1; cout << "Enter the second number: "; cin >> num2; average=(float)(num1+num2)/2; cout<<"Average is: "<<average; getch(); } #include<iostream.h>

Object Oriented Programming Practical 3 Read More »

Object Oriented Programming Practical 2

Object Oriented Programming Practical 2 Question 1 Write a C++ program to access the global variable using scope resolution operator. global.cpp C #include<iostream.h> #include<conio.h> int num=100; void main() { clrscr(); int num; cout<<"Enter number: "; cin>>num; cout<<"Value of number inside main is: "<<num<<endl; cout<<"Value of number outside main is: "<<::num<<endl; getch(); } #include<iostream.h> #include<conio.h> int

Object Oriented Programming Practical 2 Read More »

Object Oriented Programming Practical 1

Object Oriented Programming Practical 1 Question 1 Write a C++ program to evaluate the following expressions: X=(-b-(b2-4ac))/2a expression.cpp C #include<iostream.h> #include<conio.h> #include<math.h> void main() { clrscr(); int a,b,c,d; cout<<"Enter value of a,b and c"<<endl; cin>>a>>b>>c; d=(-b-(b*b-4*a*c))/(2*a); cout<<"Value= "<<d<<endl; getch(); } #include<iostream.h> #include<conio.h> #include<math.h> void main() { clrscr(); int a,b,c,d; cout<<"Enter value of a,b and c"<<endl;

Object Oriented Programming Practical 1 Read More »

Mobile Application Development Practical 33

Mobile Application Development Practical 32 Question 1 Write a program to locate user’s current location. AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/Theme.Practical31" tools:targetApi="31"> <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyAAl7T5IB74VSYRkOVs1F25Vv_EtKJKddA" /> <activity android:name=".MapsActivity" android:exported="true" android:label="@string/title_activity_maps"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />

Mobile Application Development Practical 33 Read More »

Programming With Python Practical 16

Programming With Python Practical 16 Question 1 Write a Python program to Check for ZeroDivisionError Exception. division.py num1=int(input("Enter a numerator: ")) num2=int(input("Enter a denominator: ")) try: result=num1/num2 print("Division is: ",result) except ZeroDivisionError: print("Denominator can not be zero") Output Question 2 Write a Python program to create user defined exception that will check whether the password

Programming With Python Practical 16 Read More »

Programming With Python Practical 15

Programming With Python Practical 15 Question 1 Create a class Employee with data members: name, department and salary. Create suitable methods for reading and printing employee information emp.py class Person: name="" def getData(self,n): self.name=n def putData(self): print("Name is: ",self.name) class Employee(Person): department="" salary=None def get(self,dep,sal): self.department=dep self.salary=sal def put(self): print("Department is: ",self.department) print("Salary is: ",

Programming With Python Practical 15 Read More »