Skip to main content

Posts

Showing posts from October, 2021

Write a program for multiplication of two numbers using Template function in C++

  Problem Statement: Write a program for the multiplication of two numbers using the template function . Note :- Scroll horizontally to see the full line of code. #include <iostream> using namespace std ; template < typename T > void multiply ( T a , T b ){     cout << "Multiplication is:" << a * b << endl ; } int main (){     int a , b ;     cout << "Please Enter Numbers:" ;     cin >> a >> b ;     multiply ( a , b );     return 0 ; }

Implementation of Sorting Algorithms using Python | Quick Sort | Partition Function

Problem Statement:  Write a Python program to store first year percentage of students in array. Write function for sorting array of floating point numbers in ascending order using quick sort and display top five scores. Note :- Scroll horizontally to see the full line of code. def swap ( arr , i , j ):     temp = arr [ i ]     arr [ i ]= arr [ j ]     arr [ j ]= temp def partition ( arr , start , end ):     pivot = arr [ end ]     i = start - 1     for j in range ( start , end ):         if ( arr [ j ]< pivot ):             i = i + 1             swap ( arr , i , j )     swap ( arr ,( i + 1 ), end )     return ( i + 1 ) def quick_sort ( arr , start , end ):     if ( start < end ):         pivot = partition ( arr , start , end )         # print("Pivot element i...

Implementation of Sorting Algorithms using Python | Insertion Sort | Shell Sort

  Problem Statement: Write a Python program to store second year percentage of students in array. Write function for sorting array of floating point numbers in ascending order using      a) Insertion sort     b) Shell Sort and display top five scores. Note :- Scroll horizontally to see the full line of code. def insertion_sort ( a , n ):     for i in range ( 1 , n ):         current = a [ i ]         j = i - 1         while (( a [ j ]> current ) and j >= 0 ):             temp = a [ j + 1 ]             a [ j + 1 ]= a [ j ]             a [ j ]= temp             j = j - 1         a [ j + 1 ]= current         print ( "Iteration" , i , ": " , a )     return a def shell_sort ( a , n ):     gap = n // 2 ...

Implementation of Searching in an Array by using pointer to Array in C++ | Pointers in C++

  Problem Statement:- Implement a program that takes input as an array and search for an element in the array and return the index of the element using pointers in C++. Note:-  Scroll horizontally to see the full line of code. #include <iostream> using namespace std ; int main () {     int arr [ 5 ];     int * ptr = arr ;     int i = 0 ;     while ( i < 5 ){         cout << "Enter the element: " ;         cin >> *( ptr + i );         i ++;     }     cout << "Array is: " ;     for ( int i = 0 ; i < 5 ; i ++){     cout << arr [ i ] << " \t " ;     }     cout << endl ;         int n ;     cout << "Enter the element to be searched: " ;     cin >> n ;     i = 0 ;     int flag = 0 ;     w...

Implementations of Search Algorithms using Python | Linear Sequential Search | Sentinel Sequential Search | Binary Search | Fibonacci Search

  Problem Statement:-  a) Write a Python program to store roll numbers of student in array who attended training program in random order. Write function for searching whether particular student attended training program or not, using Linear search and Sentinel search. b) Write a Python program to store roll numbers of students array who attended training program in sorted order. Write function for searching whether particular student attended training program or not, using Binary search and Fibonacci search. Note:-  Scroll horizontally to see the full line of code. def linear_search ( a , target ):     for i in range ( len ( a )):         if ( a [ i ]== target ):             print ( "Roll no." , target , "is present at index" , i )             break     else :         print ( "Roll no." , target , "not found in list" ) def binary_search ( a , targ...

Inheritance in C++ | Program for Inheriting book and audio cassette version class from a base class as Publishing Company with Exception Handling in CPP

  Problem Statement: Imagine a publishing company which does marketing for book and audio cassette versions. Create a class publication that stores the title (a string) and price (type float) of publications. From this class derive two classes: book which adds a page count (type int) and tape which adds a playing time in minutes (type float). Write a program that instantiates the book and tape class, allows user to enter data and displays the data members. If an exception is caught, replace all the data member values with zero values. Note:-  Scroll horizontally to see the full line of code. #include <iostream> #include <string.h> using namespace std ; class publication {     protected:     string title ;     float price ;     public:     publication (){         title = "Publication name" ;     }     ~publication (){         // cout<<"Inside Dest...

Operation on Complex numbers using Operator Overloading in C++ | Overloading Insertion and Extraction Operators in C++

Problem Statement: Implement a class Complex which represents the Complex Number data type. Implement the following     1. Constructor (including a default constructor which creates the complex number 0+0i).     2. Overload operator+ to add two complex numbers.     3. Overload operator* to multiply two Complex numbers.     4. Overload operators << and >> to print and read Complex Numbers. Note:-  Scroll horizontally to see the full line of code. #include <iostream> using namespace std ; class complex { private:     float real , img ; public:     complex ()     {         real = 0 ;         img = 0 ;     }         friend ostream & operator<< ( ostream & output , complex & D ) {           output << D . real << "+" << D . img << "i \n " ;   ...

Landing Page of a NGO Website using HTML and CSS | Non-responsive Web Design | Static Webpage

Problem Statement:-  Landing Page of an NGO Website using HTML and CSS | Non-responsive Web Design | Static Webpage. Image of Final Version of the website:- Sources of Images and logo used in Website Design: logo.png bg2.jpg HTML and CSS code:- Note:- Scroll horizontally to see the full line of code. <! DOCTYPE   html > < html   lang = "en" > < head >      < meta   charset = "UTF-8" >      < meta   http-equiv = "X-UA-Compatible"   content = "IE=edge" >      < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >      < title > Welcome to NGO </ title >      < link   rel = "preconnect"   href = "https://fonts.gstatic.com" >      < link   href = "https://fonts.googleapis.com/css2?family=Oranienbaum&display=swap" ...