beginner or easy programs in c and c++-

Fibonnaci Series Program

image

To understand this you have to clear some topics/concepts: -

  1. Operators in C

  2. while, do while loop and for loop

  3. break and continue

The fibonacci series is : 0,1,1,2,3,5,8,13,21 It is a sequence where the next term is the sum of previous two terms .The first two terms of the fibonacci sequence are followed by 0 and 1

Area of a circle // program 2**

image

Algorithm :-

Step 1 :- Start

Step 2 :- Float radius and double area

Step 3 :- Print radius

Step 4 :- Area of a circle( area = 3.14 *radius *radius)

Step 5 :- Print the area of circle

step 6 :- Exit

conversion integer into corresponding floating number :-

//program 3

**Algorithm **:-

step 1 :- Start

step 2 :- print integer number and float number

step 3 :- float number = integer number

step 4 :- exit

greatest number

Algorithm

Step 1 :- Start

step 2:- Print a, b and c

step 3:- If a>b do

if a>c

print a is greater than b and c

else b>a and b>c

print b is greater than a and c

else print c is greater

step 4:- Exit

LINEAR SEARCH PROGRAM USING AN ARRAY

STEP 1 :- set i to 1

STEP 2 :- if i>n then go to step 7

STEP 3 :- if A[i] = x then goto step 6

STEP 4 :- Set i to i+1

STEP 5 :- Go to Step 2

STEP 6 :- Print element x found at index i and go to step 8

STEP 7 :- Print element not found

STEP 8 :- Exit