This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initialize an empty list - | |
my_queue = [] | |
# Function to enqueue element | |
def enqueue(my_queue): | |
item = int(input("Enter element to enqueue: ")) | |
my_queue.append(item) | |
# Function to dequeue element | |
def dequeue(my_queue): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
// class for individual node (you can also use struct) | |
class node { | |
public: | |
int data; // to store information/element | |
node *next; // points to the location of the next element | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Program to demonstrate array of objects in Java - | |
package array; | |
import java.util.Scanner; // For taking user input | |
class Student { | |
private int rno, marks; | |
private String name; | |
// Function for getting data from user input - | |
public void getData() { | |
Scanner sc = new Scanner(System.in); | |
System.out.println("Enter roll no: "); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Program to demonstrate initializing of arrays, take user input, and display elements of the array | |
#include <iostream> | |
using namespace std; | |
int main() { | |
char a[] = {'a', 'b', 'c', 'd', 'e'}; // initialize hard-coded char array (stores only characters) | |
int arr[5]; // initialize integer array of size 5 | |
cout << "Enter array elements: " << endl; // displays message to enter array elements | |
// for loop, where iteration variable i is initialized to 0 | |
// i goes on upto (not including) 5 (i.e. size of the array) | |
// i is incremented by 1 in every iteration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Program to demonstrate abstract classes in Java - | |
package abstractClass; | |
// No function definition can be added | |
// Objects of abstract class cannot be created,but object references can be created | |
// Syntax: abstract type method-name(parameter-list); | |
// abstract class class-name {} | |
// No abstract constructors | |
// Abstract class must be a subclass | |
abstract class area { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Case Study - | |
Using concepts of object-oriented programming develop solution for banking system having the following operations - | |
1. Create an account | |
2. Deposit money | |
3. Withdraw money | |
4. Honor daily withdrawal limit | |
5. Check the balance | |
6. Display account information | |
*/ |