CSE 506 Lab 5

CSE 506 Lab 5

Practise #1 (Eg 6.1)

Write a code to find the greater signed number of the numbers stored in AX and BX

ABC:
mov ah, 1
int 21h
mov bl, al

int 21h
mov bh, al

cmp bl, bh
jG point1
jl point2

point1:
mov ah, 2
mov dl, '>'
int 21h
jmp ABC

point2:
mov ah, 2
mov dl, '<'
int 21h

jmp ABC

Practise #2
Print 80 star using condition

mov cx, 80
point1:
mov ah, 2
mov dl, '*'
int 21h
dec cx
jnz point1

Problem #1
Print 10*10 box with star (*) without using string and using conditions

Practise #3 (eg 6.2)
Replace a number with absolute number

mov ax,0FFFBh

cmp ax, 0
jnl point1
neg ax

point1:

Practise #4 (eg 6.3)
Suppose AL and BL contain extended ASCII characters. Display the one that comes first in the character sequence.

MOV AH,2
CMP AL,BL
JNBE NOT_AL
MOV DL,AL
JMP DISPLAY
NOT_AL:
MOV DL,BL
JMP DISPLAY
DISPLAY:
INT 21h

 

CSE 506 Lab 4

Problem #1
Write· a program to read one of the hex digits A-F, and display it on the next line in decimal.
Sample execution:

ENTER A HEX DIGIT: C 
IN DECIMAL IT IS 12

Problem #2
Write a program to display a 10 x 10 solid box of asterisks.
Hint: declare a string in the data segment that specifies the box, and display it with INT 2lh, function 9h.

 

Problem #3
Write a program to (a) display”?”, (b) read three initials,(c) display them in the middle of an 11 x 11 box of asterisks

Submit the lab codes using this link

EEE 306 Lab 3 : Sand castle in C beach

P.S. This lab is not related to numerical analysis. This lab is about basic C and is on students request.

Problem #1

Print a half pyramid

#include <stdio.h>

int main() {
 int i, j, n;
 printf("\nNumber of line is ");
 scanf("%d",&n);

for(i = 0; i < n; i++) {
 for (j = 0; j <= i; j++) {
 printf("*");
 }
 printf("\n");
 }
 getchar();
 return 0;
}

 Problem #2

Draw a 5 level pyramid

#include <stdio.h>

int main() {
 char line1[] = "*";
 char line2[] = "**";
 char line3[] = "***";
 char line4[] = "****";
 char line5[] = "*****";

printf("%40s\n",line1);
 printf("%40s*\n",line2);
 printf("%40s**\n",line3);
 printf("%40s***\n",line4);
 printf("%40s****\n",line5);

return 0;
}

 Problem #3

Scan for n inputs and only take positive inputs

#include <stdio.h>

int main() {
 int arr[100], n, i, temp;

scanf("%d", &n);

i = 0;
 while(i < n) {
 scanf("%d",&temp);

if(temp > 0) {
 arr[i] = temp;
 i++;
 }
 }

for(i = 0; i < n; i++) {
 printf("%d ", arr[i]);
 }

return 0;
}

 Problem #4

Take a string input and check for number of vowels in the string

#include<stdio.h>
int main()
{
 int i, vowel=0;
 char str[1300];
 printf("type ur string\n\n");
 scanf("%[^\n]s", &str);
 for(i=0; str[i]!='\0'; i++){
 if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='A'||str[i]=='E'||str[i]=='I'||str[i]=='O'||str[i]=='U')
 {
 vowel++;
 }}
 printf("no of vowel is %d", vowel);
}

 Problem #5

Take a string input and show the number of letters in the string and convert them to uppercase

#include <stdio.h>
#include <ctype.h>

int main() {
 char str[1000];
 int i;

scanf("%[^\n]s", str);

for(i = 0; str[i]; i++) {
 str[i] = toupper(str[i]);
 }

printf("Length = %d\n", i);
 printf("%s", str);

return 0;
}

 Problem #6

Take a number input and check if the number is prime or not.

#include <stdio.h>
int main()
{
int i, n, j=0;
printf("The number to be tested is ");
scanf("%d", &n);

for (i=1; i <= n; i++)

{ if ( n % i == 0 ) {j++;} 
 }

if(j==2)
{printf("%d is a prime number.", n);
}
else {printf("%d is not a prime number", n);
}
return 0;
}

CSE 506 Lab 3

Problem #1

Write an assembly code that will take a lowercase character input and convert it to uppercase

The code is as follows

TITLE Lower_letter_to_upper
.MODEL SMALL
.STACK 100H
.DATA
 CR EQU 0DH
 LF EQU 0AH
 MSG1 DB 'Enter the letter in lower case : $'
 MSG2 DB 0DH,0AH,'In upper case is: '
 CHAR DB ?,'$'
.CODE
MAIN PROC
 MOV AX,@DATA 
 MOV DS,AX
 
 
 LEA DX,MSG1
 MOV AH, 9
 INT 21h
 
 MOV AH,1
 INT 21h
 SUB AL,20H
 MOV CHAR,AL
 
 LEA DX,MSG2
 MOV AH,9
 INT 21h
 
 MOV AH,4CH
 INT 21H

MAIN ENDP
 END MAIN

The main segment operating the code is

 MOV AH,1
 INT 21h
 SUB AL,20H
 MOV dl,AL
 mov ah, 2
 int 21h

Problem #2

Write a program to (a) display a “?”, (b) read two decimal digits whose sum is less than 10, (c) display them and their sum on the next line, with an appropriate message.

Sample execution: 
?27 
THE SUM OF 2 AND 7 IS 9

Problem #3
Write a program to (a) prompt the user, (b) read first, middle, and last initials of a person’s name, and (c) display them duwn the left margin.
Sample execution:

ENTER THREE INITIALS: JFK 
J 
F
K

 

Submit Assignment 2 through this link

Starting with building circuit

If you are fairly new to building a circuit on a breadboard, you may face difficulty in EEE labs.

Few years back i wrote a series of blog post on absolute basic to starting to build circuits. I hope these can help you if you find it difficult to build a circuit in a breadboard.

  1. ইলেকট্রনিক্স : শেখার শুরু

  2.  ইলেকট্রনিক্স : শুরু করতে যা লাগবে

  3.  ইলেকট্রনিক্স : শুরু করতে ইলেকট্রিকের যা যা জ্ঞান লাগবে

  4.  ইলেকট্রনিক্স : ব্রেডবোর্ডে পরিচিতি

  5.  ইলেকট্রনিক্স : প্রথম ব্রেডবোর্ডে সার্কিট

  6. ইলেকট্রনিক্স : রেসিস্টর