Bachelor of Technology in Information Technology


rite a C program to find the Fibonacci Series ALGORITHM



Download 0,65 Mb.
bet9/14
Sana20.03.2022
Hajmi0,65 Mb.
#502184
1   ...   6   7   8   9   10   11   12   13   14
Bog'liq
PSP Lab Manual

rite a C program to find the Fibonacci Series ALGORITHM:


Step 1: Start.
Step 2: declare i, t1 = 0, t2 = 1, next, a. Step 3: print enter the value of a.

Step 4: read a.


Step 5: print Fibonacci series is Step 6: repeat until i<=a
Print next next← t1 + t2 t1 ← t2
t2 ← next
Step 7: Stop.


SOURCE CODE:


#include int main()
{
int i,t1 = 0, t2= 1, next, a;

printf("Enter the value of a:\n"); scanf("%d", &a);


printf("%d %d:\n", t1,t2);


for(i=1;i<=a-2;i++)


{
next =t1 + t2; t1 = t2;
t2 = next; printf("%d\n", next);
}

return 0;


}


Simple programming for one dimensional and two dimensional arrays.


  1. Linear Search


ALGORITHM:

STEP 1: Start


STEP 2: Declare the variables N, a[N], search, i, flag = 0 STEP 3: //Input the values of N=5 in an array a[5]
for(i = 0; i<=N; i++)
Input the value of ‘N’ at location a[i] STEP 4: for(i=0; iDisplay the value of ‘N’ at a[i] location
STEP 5: Input the value of ‘search’ you want to search in an array a[i] if(a[i] == search)
then display ‘search’ value found at location a[i] flag++
STEP 6: if(flag == 0)
then display ‘search’ value not found else
display number of occurrences of ‘search’ value STEP 7: Stop

SOURCE CODE:


#include


#include #define N 5
#include
#define N 5
void main()
{
int search, a[N];
int i, flag=0;
for(i=0; i{
printf("Enter the element at location %d \n", i);
scanf("%d",&a[i]);
}
for(i=0; i{
printf("element at location %d is %d \n", i, a[i]);
}
printf("Enter the number you would wish to search\n");
scanf("%d", &search);
for(i=0;i{
if(a[i]==search)
{
printf("Number found at location %d\n", i);
flag++;
}
}
if(flag==0)
printf("Number not found");
else
printf("Occurrences = %d ", flag);
getch(); }
--------------------------*-----------OUTPUT----------------*------------------------





  1. Download 0,65 Mb.

    Do'stlaringiz bilan baham:
1   ...   6   7   8   9   10   11   12   13   14




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish