Posts

Showing posts from December, 2020

Simple Phone directory system without using structure/Classes in c++

Telephone Directory System #include<iostream>//headerfile #include<string>//headerfile using namespace std; int top = 0;//globle variable //functions void addPhone(string *N,string *Ad,string *No,int *ID,int size) { if (top >= size){ cout << "We cannot add more Data there" << endl; } else{ cout << "Enter the ID:"; cin >> ID[top]; cin.ignore(); cout << "Enter the phone number:"; getline(cin, No[top]); cout << "Enter the Name:"; getline(cin, N[top]); cout << "Enter the Address:"; getline(cin, Ad[top]); top++; } } void Modify(string *N, string *Ad, string *No, int *ID, int size) { int count = 0; int id; cout << "Enter the number to Modify" << endl; cin >> id; for (int i = 0; i < top; i++){ if (ID[i] == id){ cout << "Enter the ID:"; cin >> ID[i]; cin.ignore(

BST Implementation using Recursive and iterative Process(insertion+InOrder, PreOder,PostOrder)

Search Binary Tree Implementation using Recursive an iterative Process  #include<iostream>//headerfile using namespace std;//for std #define size 20 //fix the size struct Tree{ int data; Tree *left; Tree *right; }; struct Stack{ //creation of stack Tree *arr[size]; int top = -1; bool isEmpty() //to check stack tat is this empty { return (top < 0); } bool isFull() //to check stack is this full { return (top == size - 1); } void push(Tree *v) //to push the adress inside the stack { if (isFull()) { cout << "Value cannot Store" << endl; } else { arr[++top] = v; } } Tree *pop() //to pop the address from stack { if (isEmpty()) { cout << "There is nothing o display" << endl; } else { Tree *v = arr[top--]; return v; } } Tree *peek() //to check the top adress { if (isEmpty()) {

How to find the Factorial and Sum of Series Number using Recursion in c++

 Implementation of Recursion #include<iostream>//headerfile using namespace std;//for std #define size 5//fixed size struct Stack{ //to make stack int arr[size]; int top = -1; bool isEmpty()//to check stack is this empty { return (top < 0); } bool isFull()//to check stack is this full { return (top == size - 1); } void push(int n) //to push the value and store it into the stack { if (isFull()) { cout << "Stack is Full" << endl; } else { arr[++top] = n; } } int pop()//to remove the value from stack { if (isEmpty()) { cout << "There is nothing to show" << endl; } else { int a = arr[top--]; return a; } } int peek()//to remove or check the top of the stack { if (isEmpty()) { cout << "There is noting to show" << endl; } else { int a = arr[top]; return a; } } int sum(int n)//Recusrive function to make sum { if (n <= 1) { re

Use of loops(for/while/do while) in Assembly language in MIPS on Mars(Programs)

  U se of loops #Task 1 : #Write a MIPS program to print all natural numbers from 1 to n. using while loop .data msg1: .asciiz "Natural Numbers are \n" num1:.word 1 num2:.word 100 .text lw $t1,num1 lw $t2,num2 addi $t3,$t3,0 li $v0,4 la $a0,msg1 syscall while: blt $t3,$t2,print li $v0,10 syscall print: add $t3,$t3,$t1 li $v0,1 move $a0,$t3 syscall j while #Task 2 : #Write a MIPS program to print all natural numbers #in reverse (from n to 1). using while loop. .data msg1: .asciiz "Natural Numbers are \n" num1:.word 1 num2:.word 0 .text lw $t1,num1 lw $t2,num2 addi $t3,$t3,100 li $v0,4 la $a0,msg1 syscall while: bgt $t3,$t2,print li $v0,10 syscall print: sub $t3,$t3,$t1 li $v0,1 move $a0,$t3 syscall j while #Task 3 : #Write a MIPS program to print all odd number between 1 to 100. #using do while loop. .data msg1: .asciiz "odd Numbers are \n" msg2:.asciiz"This is even number\n" msg3:.asci

How to use if/else or branches statement in Assembly language in MIPS on Mars(Program)

       Use of Branch Statement in MIPS  Task 1: Write a program to assign grades (A, B, C) based on marks obtained by a student.        I.             if the percentage is above 90, assign grade A     II.             if the percentage is above 75, assign grade B   III.             if the percentage is above 65, assign grade C .data total:.asciiz "Enter the total Marks:" obtain:.asciiz "Enter the obtained marks:" grade:.asciiz "Your marks are:" A:.asciiz "\nA grade\n" B:.asciiz "\nB grade\n" C:.asciiz "\nC grade\n" D:.asciiz "\nLess than 65%\n" num1:.word 90 num2:.word 75 num3:.word 65 num4:.word 100 .text lw $t5,num1 lw $t6,num2 lw $t7,num3 lw $t8,num4 main: li $v0,4 la $a0,total syscall li $v0,5 syscall move $t1,$v0 li $v0,4 la $a0,obtain syscall li $v0,5 syscall move $t2,$v0 li $v0,4 la $a0,grade syscall mul $t3,$t2,$t8 div $t4,$t3,$t1 li $v0,1 move $a0,$t4 syscall bge

Perform Multiplication and division of Float Number in Assembly language MIPS on Mars

  Division and Multiplication in MIPS Task 1:  program to take two float numbers from user and perform division, also display the result. .data cin:.asciiz"Enter 1st num:" cin1:.asciiz"Enter 2nd num:" cout:.asciiz"Your div is:" .text li $v0,4 la $a0,cin syscall li $v0,6 syscall li $v0,4 la $a0,cin1 syscall mov.s $f1,$f0 li $v0,6 syscall li $v0,4 la $a0,cout syscall mov.s $f2,$f0 div.s $f4,$f1,$f2 li $v0,2 mov.s $f12,$f4 syscall Task 2:  Write a program to take two double numbers and perform multiplication, and also display the result. .data cin:.asciiz"Enter 1st num:" cin1:.asciiz"Enter 2nd num:" cout:.asciiz"Your mul is:" .text li $v0,4 la $a0,cin syscall li $v0,7 syscall li $v0,4 la $a0,cin1 syscall mov.d $f2,$f0 li $v0,7 syscall li $v0,4 la $a0,cout syscall mov.d $f4,$f0 mul.d $f6,$f2,$f4 li $v0,3 mov.d $f12,$f6 syscall