Thursday, August 29, 2024

Python Program to Print all Prime Numbers in a range

 Python program to display all the prime numbers within a range

lower = int(input("enter a number")

upper = int(input("enter a number")


print("Prime numbers between", lower, "and", upper, "are:")


for num in range(lower, upper + 1):

   # all prime numbers are greater than 1

   if num > 1:

       for i in range(2, num):

           if (num % i) == 0:

               break

       else:

           print(num)

Python Program to Check Prime Number

 Python Program to Check Prime Number


num = int(input("Enter a number: "))

flag = False

if num == 0 or num == 1:

    print(num, "is not a prime number")

elif num > 1:

    for i in range(2, num):

        if (num % i) == 0:

            flag = True

            break

    if flag:

        print(num, "is not a prime number")

    else:

        print(num, "is a prime number")


Factorial of a Number using Loop

 

Factorial of a Number using Loop


num = int(input("Enter a number: "))

factorial = 1

if num < 0:

   print("factorial does not exist for negative numbers")

elif num == 0:

   print("The factorial of 0 is 1")

else:

   for i in range(1,num + 1):

       factorial = factorial*i

   print("The factorial of",num,"is",factorial)

FOR loop in PYTHON

 1.     Factorial of a Number using Loop  CLICK

2.   Python Program to Check Prime Number  CLICK

3.  Python Program to Print all Prime Numbers in a range click

4. Perfect Number by using For_loop CLICK

Python Program to Check Leap Year

 Python Program to Check Leap Year;:

year = int(input("Enter a year: "))




if (year % 400 == 0) and (year % 100 == 0):

    print( year, "is a leap year")

elif (year % 4 ==0) and (year % 100 != 0):

     print( year, "is a leap year")

else:

   print( year, "is not  a leap year")

Python Program to Find the Largest Among Three Numbers

 Python Program to Find the Largest Among Three Numbers:


num1 = float(input("Enter first number: "))

num2 = float(input("Enter second number: "))

num3 = float(input("Enter third number: "))


if (num1 >= num2) and (num1 >= num3):

   largest = num1

elif (num2 >= num1) and (num2 >= num3):

   largest = num2

else:

   largest = num3


print("The largest number is", largest)

Python Program to Check if a Number is Odd or Even

Python Program to Check if a Number is Odd or Even;


num = int(input("Enter a number: "))

if (num % 2) == 0:

   print("{0} is Even".format(num))

else:

   print("{0} is Odd".format(num))

8085 PRACTICAL

1. Program name :A=07H,B=08H,A=A+B.Find the content of A and B.

2. Program name : B=10,C=12,D=B+C.Find the content of D.

3. Program name:B=(200) BASE 10,C=B’(1’s complement of B).Find the content of C.

4. Program name :D=(200)10,C=2’s complement of D.Find the content of C.

5. Program name :D=-1,B=+1,C=B+D.Find the content of C.

6. Program name :D=55H,E=56H,C=D-E.Find the content of C.

7. Program name :D=55H,E=56H,H=D-E using 2’s complement addition.Find the content of H.

8. Program name :B=20H,C=30H,Swap B & C.Find the content of B & C.

9. Program name :Swap the content of 5000H and 3000H.

10. Program name :3000H=data1,4000H=2’s complement of data1.Find the content of 4000H.

11. Program name :3000H=data1,3001H=data2,3002H=data1+data2.Find the content of

3002H.

12. Program name :3000H=data1,3001H=data2,3002H=data3,3003H=data1+data2+data3.

Find the content of 3003H.

13. Program name :3000H=data1,3001H=data2,3002H=data1+data2,3003H=data1-data2.

Find the content of 3002H and 3003H.

14. Program name :A=20H.Add data byte 30H with immediate Acc with carry 1.

15. Program name :A=20H.Add data byte 30H with immediate Acc with carry 0.

16. Program name : A=20H,B=30H.Add register B to Acc with carry 1.

17. Program name :A=20H,B=30H.Add register B to Acc with carry 0.

18. Program name :A=20H.Add the data byte 30H immediate to Acc .Find the content of Acc

after execution

19. Program name :A=FFH,B=88H,data byte=11H.C=11H AND Acc,D=C AND B.Find the

content of C and D.

20. Program name :A=FFH,B=88H,Data byte=11H.C=11H OR Acc,D=C OR B.Find the content

of C and D.

21. Program name :A=FFH,B=88H,Data byte=11H.C=11H XOR Acc,D=C XOR B.Find the

content of C and D.

22. Program name :1st law of DeMorgan’s Theorem:(A+B)’=A’.B’.C=LHS & D=RHS.When

A=01H & B=00H,then find the content of C and D.

23. Program name :2nd law of DeMorgan’s Theorem:(A.B)’=A’+B’.C=(A.B)’ & D=A’+B’.When

A=01H & B=00H,then find the content of C and D.

24. Program name :Acc=10H,B=20H;A=Acc+B (Using Jmp instruction).

25. Program name :A=0AH.After RAL(Rotate Acc Left) move the result in C.Find the content of

C.

26. Program name :A=0AH & Carry=1.After RAL(Rotate Acc Left) move the result in C.Find the

content of C.

27. Program name :Input a number in C register & then multiply with 4 & save it into D

register.Find the content of D.

28. Program name :16 bit addition.4000H=Data 1(L),4001H=Data 1(H),4002H=Data 2(L),

4003H=Data 2(H).4004H=Sum(L),4005H=Sum(H).Find the contents of 4004H & 4005H.


29. Program name :Sum(16 bit) of two 8 bit datas.4000H=data 1,4001H=data 2,

4002H=Sum(L),4003H=Sum(H).Find the content of 4002H & 4003H.


30. Program name :4000H=data 1.If data 1 is even no.,then D=00H,otherwise D=01H.


31. Program name :4000H=data 1.If data 1 is even no.,then D=00H,otherwise D=01H.Do it

using If-else.


32. Program name :5000H=data 1.If data 1 is +ve,then store 5001H with FFH,otherwise store

with 00H.


33. Program name :1+2+3+.....+10(using loop)


34. Program name :1+2+3+.....+100.Result=8 bit.Store the result in D register.Find the content

of D.


35. Program name :1+2+3+.....+50.Result=8 bit.Store the result in D register.Find the

result(content of D).


36. Program name :1+2+3+...+100=Sum of series=16 bit.D=Sum(H),E=Sum(L).Find the

content of D and E.


37. Program name :2500H=data 1,2501H=data 2,2502H=data 3,25003H=data 4.

3000H=Sum(H),3001H=Sum(L).Find the content of 3000H and 3001H.


38. Program name :3000H=data.If no. is even positive,then store FFH in D register,but if it is

even negative,then store FFH in E register.


39. Program name :3000H=data.If no. is even positive,store 3001H with AAH,if even

negative,then store 3001H with BBH,if odd positive,store 3001H with CCH,if odd negative,then

store 3001H with DDH.


40. Program name :3001H=data 1,3001H=data 2,3002H=data 3,3003H=data 4.3004H=total

number of even number,3005H=total number of odd number.Find the content of 3004H &

3005H.


41. Program name :3000H=data 1,3001H=data 2,3002H=data 3,3003H=data 4.4000H=even

positive,4001H=even negative,4002H=odd positive,4003H=odd negative.


42. Program name :Memory Implementattion


43. Program name :5000H=11H,5001H=22H,5002H=Sum(8 bit).Find the content of 5003H.


44. Program name :Sum of 10 numbers,result=8 bit,starting memory location is

5000H.5000H=data 1,5001H=data 2,........,5009H=data 10.


45. Program name :Sum of 10 numbers,result=16 bit,starting location=5000H.

6000H=(sum)lower , 6001H=(sum)upper.Find the content of 6000H & 6001H.


46. Program name :Sum of n numbers(n=11),A=result=8 bit,starting location=5000H.Find A.


47. Program name :Sum of n no.,result=16bit.6000H=(sum)upper, 6001H=(sum)lower


48. Program name :HL=5000H,DE=3000H.Exchange HL & DE.


49. Program name :Block transfer(10 data).3000H=data 1,3001H=data 2,...3009H=data

10.result will be 5000H=data 1 of 3000H,.......5009H=data 10 of 3009H.


50. Program name :B=22H,C=22H.Compare B & C register,if B=C,then D=FFH,otherwise

D=00H.


51. Program name :LINEAR SEARCH:Count the total number of 0 from an array of n-bit.


52. Program name :Count the total number of FFH from an array of n-bit.


53. Program name :Count the total number of even number & odd number (using memory).


54. Program name :Input a no. from memory location 3000H & convert it into ASCII & save it in

4000H.


55. Program name :Input-->3000H=data 1...Output-->4000H=(a)0 for invalid no. , (b)1for valid

no.....4001H=(a)00 for invalid no., (b)ASCII for valid no.


56. Program name :INPUT-->4000H=data 1,4001H=data 2,4002H=data3

.OUTPUT-->5000H=largest number.Find the content of 5000H.


57. Program name :BINARY TO GRAY CODE:--Input a number from 3000H & convert the no.

into gray code & store it in 4000H.


58. Program name :MULTIPLICATION USING REPEATED ADDITION(4 bit*4bit =8bit):------

5*3=15.


59. Program name :MULTIPLICATION USING REPEATATIVE ADDITION(8bit *8bit = 16bit):-

10H * 11H.[(16)10*(17)10]


60. Program name :Count the total number of 1 of 8 bit number.


61. Program name :Count the total number of 0 &1 of a 8bit number.


62. Program name :Palindrome checking:-Input-->3000H=data.Output-->4000H=00H if not

palindrome,otherwise store FFH.


63. Program name :Seperate 2 nibbles:--3000H=10100111(A7H).4000H=upper

nibble=00001010 , 4001H=lower nibble=00000111.


64. Program name :3000H=data.4000H=FFH if two nibbles are equal,otherwise store 00H.


65. Program name :3000H=data.,right shift 4 times,then store the output in 4000H.Find the

content of 4000H.


66. Program name :BCD to binary:-data=00100110=26H(BCD)=38(binary).Convert the binary

number into 26H.


67. Program name :MULTIPLICATION USING ADD & SHIFT METHOD:

Input-->3000H=multiplicant,3001H=multiplier.Output-->3002H=upper part of product

,3003H=lower part of the product.


68. Program name :DIVISION USING REPEATATIVE SUBTRACTION:I/P->D=0BH(dividend),

E=03H(divider)..Output-->B=Quotient , D=Remainder.Find out the contents of B & D.


69. Program name : Replace all 0’s with FF in the array.


70. Program name :Count the total no. of element which is greater than 55H.


71. Program name :Add content of two memory location.


72. Program name :Sub two 16-bit no.,result 16 bit.


73. Program name :8-bit data shift left,1 bit.


74. Program name :8-bit data shift right,1 bit.


75. Program name :Largest number of n-numbers.


76. Program name :Smallest number of n- numbers.


77. Program name :Gray to binary conversion.


78. Program name :Ascending order sorting(using bubble sort)


79. Program name :Descending order sorting(using bubble sort).


80. Program name :Place the content of the memory location FC50 in register B & that of

FC51 in register C.The content of FC50 & FC51 are 11H &12H respectively.


81. Program name :Place 05 in the Acc,increment it by one & store the result in the memory

location FC50H.


82. Program name :Add two 8-bit decimal number,result 16 bit.


83. Program name :8-bit decimal subtraction.


84. Program name :1’s complement of a 16-bit number.


85. Program name :2’s complement of a 16-bit number.


86. Program name :8-bit data shift left,2bit.


87. Program name :16-bit data shift left,1-bit.


88. Program name :16-bit data shift left,2-bit.


89. Program name :Find the square from look-up table.


90. Program name :Find the larger of 2 number.


91. Program name :Smallest of 2 numbers.


92. Program name :Sum of a series of 8-bit decimal number,result 16-bit.


93. Program name :Multibyte addition.


94. Program name :Multibyte decimal addition.


95. Program name :Sum of a series of multibyte decimal number.


96. Program name :Seperate the odd and even numbers from an array of 5 numbers.


97. Program name :Move a block of 10 data stored from F101H to FI0AH to a target location

from F020H to F029H in the reverse order in which they are actually stored.


98. Program name :Memory bloack transfer in overlapping order.


99. Program name :Add an array of 3 16-bit hex. No. and subtract 48H.


100. Program name :Fibonacci series.


101. Program name :Fibonacci series upto n-no. Which are greater than 0AH and smaller

than 1EH.Output stored from F100 → 0D,15.


102. Program name :Factorial of a number.












































8085

 1. 8085 THEORY

2. 8085 PRACTICAL CLICK

3. 8085 question set (Gaonkar)  CLICK

4. 8085 op code CLICK

5. 8085 assignment CLICK


Monday, July 29, 2024

add graphics.h in DEV C/C++

 

step 1: 

download files:


https://drive.google.com/file/d/1ULN_XcrbDkls2U2DlYkNM_yiua5h-_NI/view?pli=1



step 2:

Copy libbgi.a to the lib folder of Dev C++. The default location is C:\Program Files (x86)\Dev-Cpp\MinGW64\lib.


step 3: 

Copy graphics.h and winbgim.h to the include folder of Dev C++. The default location is C:\Program Files (x86)\Dev-Cpp\MinGW64\include.


step4 :

Open Dev C++ and go to Tools -> Compiler Options. Select the Parameters tab and check the box for “Add the following commands when calling the linker”.

In the linker text area, paste the following commands:


-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32


. These are the required linkers for graphics.h file.



step 5:


 #include<graphics.h>  

#include<conio.h>  

#include<stdio.h>  

int main()  

{  

    int gd = DETECT ,gm, i;  

    float x, y,dx,dy,steps;  

    int x0, x1, y0, y1;  

    initgraph(&gd, &gm, "C:\\TC\\BGI");  

    setbkcolor(WHITE);  

    x0 = 100 , y0 = 200, x1 = 500, y1 = 300;  

    dx = (float)(x1 - x0);  

    dy = (float)(y1 - y0);  

    if(dx>=dy)  

           {  

        steps = dx;  

    }  

    else  

           {  

        steps = dy;  

    }  

    dx = dx/steps;  

    dy = dy/steps;  

    x = x0;  

    y = y0;  

    i = 1;  

    while(i<= steps)  

    {  

        putpixel(x, y, RED);  

        x += dx;  

        y += dy;  

        i=i+1;  

    }  

    getch();  

    closegraph();  

}  

//ADVERTISEMENT


output>