Programing
Programing
program addition
implicit none
integer:: a, b, s
print*, "Enter the first number: "
read*,a
print*, "Enter the second number: "
read*,b
s =a+ b
print*, "The sum of the two number is ", s
end program
Output:
Input:
program new
implicit none
integer, dimension (10) newarray
integer:: i
do i =1,10
newarray(i)=i
end do
print*, "The array is ", newarray
end program
Output:
2 3 4 5
The array is 1
6 7 8 9 10
Input:
program new
implicit none
: ; matrix
inte ger, d1'mension(2,2)
.
integer :: i,J
do i=1,2
do j=l, 2 . . .
matrix(i,J)=1*J
end do
end do
print*, "The matrix is
do i=l,2
print*,matrix(i,:)
end do
end program
Output:
The matrix is
1 2
2 4
program matrix
implicit none
integer,dimension (3,3) :: a
integer :: i, j
print*, "Enter the elements of matrix A
do i = 1,3
do j = 1,3
read*, a(i,j)
end do
end do
print*, "The matrix A is
do i =1,3
print*, a (i,:)
end do
end program matrix
Output :
Output:
Input:
program function
.implicit none
integer : : x
print*, "Enter the value of x: "; read*, x
if (x .gt. 3) then
print*, "The value of S{x) 3"
else if (x .lt. -3) then
print*, "The value of S{x) -3"
else
print*, "S(x) = ", x
end if
end program function
output:
Enter the value of x
1
S(x) = 1.00000000
Input:
9. Factorial of a number
Input:
The roots are imaginary
Input :
program swap2
implicit none
real :: x, y, temp
print*, "enter the value of x
read*, x
print*, "enter the value of y
read*, y
print*, "before swaping: "
print*, "Value of x ", x
print*, "Value of y ", Y
call swap (x,y,temp) -temp = Ct
contains
subroutine swap(x,y,c) a. ~ b
implicit none
real :: x, y, c '6~ 1~
C = X
X = y
y = C
print*, "after swaping
print*, " Value of x , x
print*, "Value of y: ", y
end subroutine
end program swap2
Output:
enter the value of x
6
,. enter the value of y
8
before swaping
Value of x: 6.00000000
Value of y: 8.00000000
after swaping
Value of x 8.00000000
Value of y: 6.00000000
Input:
program addition
implicit none
integer, dimension (3,3) :: a, b, c
integer:: i, j
print*, "Enter the value of elemnts of the matrix - A
do i = 1, 3
do j = 1, 3
read*, a(i,j)
end do
end do
print*, "Enter the value of elemnts of the matrix - B
do i = 1, 3
do j = 1, 3
read*, b(i,j)
end do
end do
do i = 1,3
do j =1, 3
c(i,j) = a(i,j) + b(f,j) t111 1 1
end do
end do ,
l )
open(1,file='file.pdf',status='new')
p
open (2, file= 'file. png', status=' new 1·, / l ,
open(3,file='file.txt',status='new)
write(1,*)'matrix a is'
do i= 1,3
write(l,*)(a(i,j), j =1,3)
end do
write(l,*)'matrix bis'
do i= 1,3
write(1,*)(b(i,j), j =1,3)
end do
write(1,*)'matrix c is'
do i= 1,3
write(l,*)(c(i,j), j =1,3)
end do
close(l)
end program addition
Output:
13. Write a function to find the factorial. Hence evaluate p**2*(1 -q)/nl
Input:
program factorial
implicit none
real (kind= 16):: n, i, f, p, q, x, y
real : : z
print*, "Enter then number
read*, n
f = 1
do i = 1, n
f = f*i
end do
print*, "Factorial of", n, "is : ", f
print*, "Enter the value of p : \"
read*,p c 11 r
print*, "Enter the value of q: '\'
read*,q
X = p**2
y1-q=
z (x*y)/f
=
print*, "The value of the equation is•.z : : ", z ·
end program factorial
Output:
program summation
implicit none
real (kind= 16)::s, a
r i nt eger :: p , q, n , i, f
---
print*, "Enter the value of P
read*,P "
print*, "Enter the value of q is: ..
read*,q upper limit for n of the denominator of the equation
print•, "Enter the
read•, n
do i = 0, n
f =1
if (i > 0) then
f = f*i
end if
a= (p**2 * (1 - q)) / f
s = 0.0
s = s + a
end do "
print*, "The result of the equation is: , s
end program summation
Output:
Enter the value of p
4
Enter the value of q
8
Enter the upper limit for n of the denominator , of the equation is :
6
The result of the equation is: -18.0000000000000000000000000000000000
Input:
program array
implicit none
real :: a, b, c, d, e
read*,a, b, c, d, e
print*, "The array is II
print 7,a, b, c, d, e
7 Format (F 5.2)
end program array
Output
1.234
34.123
67.233
23.67
12.34
The array is
-- .... -_,.. l/1'4-l.lfwU
. d d'.peaJ
II •
:JO an;e" a4~ .ia~u3,, '.Jur.id
:J. f 'u 'b 'd :: Jaaaiu1
1.23
34.12
67.23
23.67
12.34
Output:
0.23E-10
The array is
0.230E-10
fo_,h,o n-
I I
1
I
- Fooi'l)OTl Known O.b fonr:nUlet. IMn-'i laFm8
SijS ~ em .i.;:i pc>O ~ OCI rn b () 8I IOA9uQ&e, ~e,d ' I
- \ZPLJ V I I ec
- u teaJt.ns I :,1I
I
J( / I ( )
/
) ) ( J i( I J
1 r ,
' t 1 rI II J( : rI j I ,
o) q~ ti en\ u<l. . com pu+ati on01 r', ii / 1 11
rK1 rn e;is l
, I I
\. Wn 'co
' n1 ' i' •: I I I ( ii }
o.. pto8oom , n on8' c.o llrnn .'
I I \ I ) \ ( ( I (
"-' Wt511e.
2· Mcoll mum. \12 chc.nm d €25~ O<le. a l\owc\,(td I Iri o..
S.ln9B \ine, 1• 111 11, 11,, 1111 1, IJ , ,, 'Jr,, 1,r, ,, ,
1
~~ ~1)F:, w I
6· Vo.~\Qb\Q
i I { I (ncr,oci
I i' I 11hu\lQ)
I ( ( I I
ma~m\ 10\I 11~hl~bc.tc.. \ ~ ~t~
. I / () i' l I ) )I J / I' • / •
, I
~~ -~~1
1
I \
ond c1a~a~~ e ,
,~ m~ ,,,·ft
\
1~ :1,Qf~li t .
I( I I // ;l I / ) 1
( (
' I I ) ' ( 1 h 11 I I
1
\/ ( <1 ( 1 I , . i ,~ i , { , i
( J ',) ) nr I' .,\ t I I l J ,
.i ,I J J /) () ' i I I
I
, I
'I
, I I
.' .
,
.
I •
l ' 3 C l)
•
- i~ \ 03i t
u.l volt.,Q, '"6e r ~e
- s~ n\01'.
b e.,n \'rn ~ ·I /:,_ Je or,
I '
~fi\l>t ::
I
e tWJ> Q. f I
I
Ill I
Q,) (,h{'lis~' c\l e , I I
I I I
' i I
' ' ·!
- ~ s\n\'0'6 I IIJ1 I I I
t - r0e.. l 1 i
~
i)\~~'6Q,n\ ~ I
,~e.{:) JP ? ~ O . ~ 11
1 11
Q) f\1S\-\hrn<2.~ CIbp \(i\ i. FpR1
R~ N,
1e ' 6 0 ~ .1' .
: n JI J 1
111
foo p e ~ H l \ l n 1 , i /
11 1
~ ' mcd~e.'f
J:.~ :- t na~,~~ oP'J~
- odch\- I
CAtiof\.
io n , '
\ •1
1
7) r ,1 , :;..u •,s
,u't;i~;ti€.lt c\- .) • 11 , \ 111 •
i omil , 1v .\\. 'l
. ;K ,I
=- . rnu\ti\)Lir \
I, I,,,1
1
,•
o~on ,, /..
,,l l Ii' )\ r 11t,
JI1 , ,, : ; 11 t:
1 ci) v\~~9'0J 1 11
1 <11i
~ ;t:.
, 0 ,,i o n, , ,J \ ,
,
- expon~ r,)¼(~ '( i , \ I )/1
( )
I
, ( , 1 l' )
\
no t .ectu OvL
I'
- '
. f\~ •
\· o~ b·
-::.)
\ ~ -\n an
I I ia-oe.o1 el'.> -\ ho n o "6
\ '
I\ ,
-- I I \
e..q, ua..l bo ·
\\ l \ / 1\, \ 1'l \
\I~ J \I I ' I I I
I , I lI I I l
I I I
l
I '
I
I
I, ,
} I
( I I ( I I
! ,I d 11! l / I~I I I I i' \ I
11 I[ )
I '
I
J I I I. /l I i lI ' I
' I
I
\
I l I ' ·( I \ i ( '( II l, I'
I
\ I I I • II I I I ,, , , f l I I (1 \
iit l) /l
/ ,.• ,. ,,, , /'',~ \
) ., I ) ) I · \
I I ' ·1 I lI . / 1·
j I
. '
1 ., 1 ,I
I
I ltl , J/ i ' j
I
II
t
r~ecedentQ ~ ope,15 Cl\-u'6 I
Tn On ex.p-is~ion , OP,e.bato~~ w'i-\h h.J8heo f1llCl'Ji ~
wi II be. e.vulua¼ed &;~ \: ·
'\
0 (\QtJ • (_ - )
E-x..ponenntltHYn
Mu\ \-i p\ ,~\i;v~. ~) I
AM,\;\J~ t J-
I
~e\o\ioncil
fciucw ~
109\Col liNi) · '
.lot\1wl. oR 1
e r' (\ \ ~
'
II (I I I I
t) 1~ - e.be. ib s\ulemQ.n\:
I
j ( I! .I I
\
i O' ( \ DfjkoJJ ''e ,~l) ~ fol1r \ \ \ ' ( Ir 1
.
l l I Al I i !\ I
rt ;- I .id o¾e.
I
Onu S 'l l
\ I~ (
(l l '_ii I
I I
Qrnern., -
1
(
1
1 ) ;
•l l
2 \~ n ~l U
,
1
a
I. P , I r:1 1.. ,, , (ll , I 1, i;,,,,. ' 1.. ' , i,~'
., , ·,J • ; , • ,
r11
I
I I I I j II I \
1 I '/ l )\ lIl ) \ ) \t f l
I. l,
I
,I I( I \ ( ,t .~ 1 I\ ()_ I (} l\ ,dil I. ., , 'i
\
\ ; I. I , (1 I
I t· \I 'i
I I I. I ~w1 \
t 1111\ ( ', : t ( { I ( .'I I } I
I. I
Sl lb p {'PU c"">l llH in ,~ ){) l U{~ 'UnN
\ I . '
l '
I
I ' •
I
'
'
I
,
U~:- , l , Il _. l (,I .i
/ I
... \. ~l,\'U 01C
. r· . l'\1nn ·, n t OVJ ~nN
\ O" u,(t ~ ... I
~cnD n. __ ,
_ /-,. . ,,on . .
.ti~\: 3v,J!J 1rde }Jo_t
Ex..omn\e i 1,, , ,
'
1
I\ ( j I ( I: \ ( ' \ I' I \ j f
f-<e.od , 5)
• l
Q \J1
11
'rnJ ,n.1 1 1 1
1i ,
1 , 11
1, I . 1 r I1 1 1
1 / 1
5 ~CY~rn()j:,1 1 ~ p 5 . 1)_
I
E .\)..•Lt) 1.5)
' I J,
'
I.
'
I
I
I
.
• ,, I l
I
Sp<2 ci &ctL\icin
1
~ ( ) ~ . DUfQbe_o 1".n f'9uc.,\ionCLL fo~rn
I\
Cod~~ r W•d
l .! I l ,
1
P ., _ ' Tu<r, ~,~W, Dumb~ \'ri t"l'iuc\ionctl. ~-om
1
\ .
f\L\°IT\0~15- 1 , l
I I l ~ \
E~·-- F 5 •2 ·
L_
-
r-;:
~ I'C \,I [~i((l Ii l) I\ di I I l I ( ff I. ,')
todQ, ~ 1w
1 ~ Tn~{:~Q,1>
Lu~ w\d1 h
E8:- I 5 I t
w = -ki-\ul
I 1
wid\h oc.c'.J
p\ Jd ; 'b~' il-Q be?) n\Jm
d ~ n O· ob di 9'i\0 cippe.o1Sl"18 +o the, o i 8ht' ct;~he
1 1
detirnol po\n\ in -1hQ,' rnuhti.).)d.' pO<".lt · '
( , I 1' . :·1 ·· < ·
1 I 1 '1
t~:- E q:2, ~is' · b-2?.t :.:.10 ..· · · , )i
I
; I ' ( J l,
. \. . ,.·. : I . · 1'