July 2017

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. ইলেকট্রনিক্স : রেসিস্টর

EEE 306 Lab 2 : Taylor’s error

Problem#1
Find the sum of the n terms for the sequence
1/(x^n)
Input: x n
output:
Term_no sum
for all term leading to n
Example input:
Example Output:

 

Problem#2
Find the approximation of e^x using maclauren series for %Ea <n%
Input: x n
Output:
interation_no approximation %Ea
for every iteration
Example input:

0.5 0.0001

Example Output:

2 Approximation=1.500000 Error=50.000000
3 Approximation=1.625000 Error=8.333333
4 Approximation=1.645833 Error=1.282051
5 Approximation=1.648438 Error=0.158228
6 Approximation=1.648698 Error=0.015798
7 Approximation=1.648720 Error=0.001316
8 Approximation=1.648721 Error=0.000094

Approximation for e^0.500000 with 0.000094% error is 1.648721

 

Submit Assignment 2 through this link

CSE 505 Assignment 1

For Assignemnt 1 you have to answer all the questions in lecture 0 to lecture 2. Only PDF files are allowed for Submission and without proper naming of the file may not make your assignment be counted for the final tally.

You have to name the file accordingly like the example below
cse_506_assignment_1_20143315**.pdf
replace ** with your roll number.

 

Submit Assignment 1 through this link

CSE 506 LAB 2

Assembly Code to print a string

.MODEL SMALL 
.STACK 100H
.DATA ;
CR EQU 0DH ;
LF EQU 0AH ;

MSG db CR, LF, 'Hello: $'

.CODE ;
MAIN PROC ;MAIN PROCEDURE ; CODE SEGMENT
 MOV AX,@DATA ;
 MOV DS, AX ;
 
LEA DX, MSG ;Print hello
mov ah,9
int 21h

 MOV AH, 4CH ;Exit code 
 INT 21H
 MAIN ENDP

END MAIN

Problem #1

Write an assembly code to print 2 different string that will be stored in 2 different variable.

Problem #2

Write an assembly code to take 3 input and print them right away.

Problem #3

Write an assembly code to take 4 inputs and print them after taking all the inputs.

example

a b c d <-- 4 inputs taken
abcd   <-- Prints

Practice #1

Practice Marut code example 4.2  for next class.