Sunteți pe pagina 1din 86

PROGRAMS USING SIMPLE STATEMENTS AND EXPRESSIONS

EX: NO: 04 (a)

PERFORM INTEGER TO FLOAT CONVERSION

FLOWCHART: Start

Read integer

b=(float)a

Print value

Stop

EX: NO: 04 (b)

MULTIPLICATION OF TWO NUMBERS

FLOWCHART:
Start

READ a, b

c=a*b;

Print c

Stop

RESULT: Thus the c program to produce the Multiplication result of given two Numbers was written, entered, executed and the output was verified.

FLOWCHART:

Start

Read the marks

tot=m1+m2+m3+m4+m5; avg=tot/5;

Display avg

Stop

RESULT: Thus the c program to calculate the Average of given five Numbers was written, entered, executed and the output was verified.

EX: NO: 04 (d) . FLOWCHART:

EVALUATION OF AN EQUATION

Start

Read v,c,g,d

nr=(2*v)+(6.22*c*d); dr=g+v; r=nr/dr;

Print r

Stop

RESULT: Thus the c program to evaluate the given Equation was written, entered, executed and the output was verified.

EX: NO: 04 (e) FLOWCHART:

PERFORM MEASUREMENT CONVERSION

Start

Read millimeter

m=mm*1000;

Print mm

Stop

RESULT: Thus the c program to convert given millimeter measurement into meter was written, entered, executed and the output was verified.

SCIENTIFIC PROBLEM SOLVING USING DECISION MAKING AND LOOPING EX: NO: 05 (a) FLOWCHART:
Start

CHECK ODD OR EVEN

Read n

rem=a%2

Is rem==0

Print even

Print odd

Stop

RESULT: Thus the c program to check whether given Number is odd or even was written, entered,executed and the output was verified.

EX: NO: 05 (b) NUMBERS

FINDING BIGGEST OF 3

FLOWCHART:
Start

Read a,b,c

Big=x

yes
Is y >big

Big=y

no

yes
Is z>big

Big=z

Print big

Stop

RESULT: Thus the c program to examine the biggest of given three numbers was written, entered,executed and the output was verified.

EX: NO: 05 (c)

FIND THE SUM OF N NATURAL NUMBERS

FLOWCHART:
Start

READ n

I=1

No
Is i<=n

yes

sum=sum+i; i++;

Print sum,n

stop

RESULT: Thus the c program to find the sum of N natural numbers for given range was written, entered, executed and the output was verified.

EX: NO: 05 (d) FLOWCHART:

FIND THE SUM OF DIGITS

Start

READ n

Sum=0

Is n>=0

yes

i=n%10; sum=sum+i; n=n/10

Print sum

stop

RESULT: Thus the c program to find the sum of digits for a given number was written, entered, executed and the output was verified.

EX: NO: 05 (e)

CHECK THE EVALUATION OF SINE SERIES

FLOWCHART:
Start

Read x,n

J= 1

for i=1;i<n*2;i+=2

sum=1

nr=pow(x,i)*j; dr=factorial(i); res+=(nr/dr); j=-j;

For i=1;i<=n;i++

sum=sum*i;
Print res

stop

RESULT: Thus the c program to find the sum of digits for a given number was written, entered, executed and the output was verified.

EX: NO: 05 (f)

CREATION OF ARITHMETIC CALCULATOR

FLOWCHART:
Start Read a,b

no
Is n<=4

&n>0

Read n B

Switch n

yes
Case 1 C=a+b

no
Case 2 C=a-b Print c

PRINT C

no
Case 3 C=a*b Print c

no
Case 4 C=a/b Print c

no
Case 0 A B Print invalid

Stop

RESULT: Thus the menu driven c program to implement an Arithmetic Calculator was written, entered, executed and the output was verified.

EX: NO: 05 (g) AIM: FLOWCHART:

TO CHECK PALINDROME

start

Read num

Is num!=0

Rem=num%10

a= =rnu m

Is

Rnum=rnum*10+rem

num=num/10

Print plindrome

Print not a palindrome

stop

RESULT: Thus the program to check the number is palindrome is verified and executed.

EX: NO: 05 (h) FLOWCHART:

CHECK PRIME OR NOT

start

Read num

i<=num-1

yes Is num%i==0

yes

Print not a prime Print prime

stop

RESULT: Thus the program to check the number is prime is verified and executed.

EX: NO: 05 (i) FLOWCHART:

CHECK ARMSTRONG OR NOT

start

Read num

Is num!=0

x=n%10; s=s+(x*x*x); n=n/10;

Is h==s

Print armstrong Print not a palindrome

stop

RESULT: Thus the program for checking the Armstrong number is verified and executed.

EX: NO: 05 (J) FLOWCHART:

CONVERT BINARY TO DECIMAL

start

Read bnum

while(b num!=0

digit=bnum%10;decimal=decimal+ (digit<<base); base=base+1; bnum=bnum/10;

Print bin decimal

stop

=4

RESULT: Thus the program for convert the binary to decimal is verified and executed.

EX: NO: 05 (K) FLOWCHART:

FIND THE FIBBONACCI SERIES

start

Print num

Is num==0

Print 0

For i=0;i<num;i++

fib=fib+a; a=b; b=fib;

stop

Print fib

RESULT: Thus the program for convert to find the fibbonacci series is verified and executed.

EX: NO: 05 (L) FLOWCHART:

FIND THE LEAP YEAR

start

Read year

Is year%4

Is leap year

Not a Leap Year

stop

RESULT: Thus the program for convert to find the leap year is verified and executed.

SIMPLE PROGRAMMING FOR ONE DIMENSIONAL AND TWO DIMENSIONAL ARRAYS EX: NO: 06 (a)
FIND THE SUM OF ARRAY ELEMENTS

FLOWCHART:
start

Read n

I=0;I<N;I++

I=0;I<N;I++

Read a[i]

sum=sum+a[i];

Print sum

stop

The Sum of Array Elements is 280 RESULT: Thus the menu driven c program to find the sum of given array elements was written, entered, executed and the output was verified.

EX: NO: 06 (B) FIND MINIMUM AND MAXIMUM OF ARRAY ELEMENTS FLOWCHART:
start

Read cnt Read table

I=0;I<N;I++

max = min = table[1]

max<table[i] No min = table[i] max = table [i] yes

I=0;I<N;I++

stop

RESULT: Thus the c program to find the max and min of given array elements was written, entered, executed and the output was verified. .

EX: NO: 06 (c)

MULTIPLICATION OF 2*2 MATRIXES

FLOWCHART:
J=0 start Is j<n

Read m,n Read a[i][j] Read b[i][j] Read r,s J=j+1

J=j+1

Is j<n

C I=i=1

C[i][j]=0 F

Is m!=r A Not mult K=0

I=0

I=0 Is i<m A E Is i<m F

stop Is i<m

J=0 D

c[i][j]=c[i][j]+ a[i][k]*b[k][j]

I=i+1

Print c[i][j]

RESULT: Thus the c program to perform 2*2 matrixes multiplication was written, entered, executed and the output was verified.

EX: NO: 06 (d)

TRANSPOSE OF A MATRIX

FLOWCHART:
start

for(i=0;i<row;i++) for(j=0;j<col;j++)

Read a[i][j

for(i=0;i<row;i++)
Print a[i][j]);

for(i=0;i<row;i++
Print a[i][j]);

stop

RESULT: Thus the c program to perform transpose of a matrix was written, entered, executed and the output was verified.

EX: NO: 06 (e)

ADDITION OF 2*2 MATRIXES

FLOWCHART:

J=0 start Is j<n

Read m,n Read a[i][j] Read b[i][j] Read r,s J=j+1

J=j+1

Is j<n

C I=i=1

C[i][j]=0 F

Is m!=r A Not mult K=0

I=0

I=0 Is i<m A E Is i<m F

stop Is i<m

J=0 D

a[i][j]+b[i][j];

I=i+1

Print c[i][j]

RESULT: Thus the c program to perform 2*2 matrixes addition was written, entered, executed and the output was verified.

EX: NO: 07 SOLVING PROBLEMS USING STRING FUNCTIONS (a) STRING PALINDROME CHECKING
:

FLOWCHART:

start

Read string S

strcmp(s, s1)==0

palindrome

Not a palindr ome

stop

RESULT: Thus the c program to check whether the given string is palindrome or not was written, entered, executed and the output was verified.

EX: NO: 07 (b)


FLOWCHART:

STRING CONCATENATION

Start

Read strings S1,S2

strcat(S1,S2)

Print the string

Stop

RESULT:
Thus the c program to find the length of given two strings and concatenate them was written, entered, executed and the output was verified.

Ex.No.7(c) STRING FUNCTIONS-COMPARE TWO STRINGS


FLOWCHART:
start

Read s1,s2

Strcmp (s1,s2)

false

true Print not equal Print equal

stop

RESULT: Thus the c program to compare two string using strcmp() function was written, entered, executed and the output was verified.

Ex.No.7(d) STRING FUNCTIONS-COPY THE STRING

FLOWCHART:
Start

Read string Strcpy

strcpy(S2,S1)

Print the string S2

Stop

RESULT: Thus the c program for copying two string using strcpy() function was written, entered, executed and the output was verified.

Ex.No.7(e) STRING CONVERSION TO LOWERCASE,UPPERCASE,STRING LENGTH

FLOWCHART:
Start

Read the string

S1=strlwr(s) S2=strupr(s) S3=strrev(s) N=strlen(s)

Print S1,S2,S3,N

Stop

RESULT: Thus the c program for converting to lowercase,uppercase and finding string length was written, entered, executed and the output was verified.

EX: NO: 08 PROGRAMS WITH USER DEFINED FUNCTIONS (a) FUNCTIONS WITHOUT ARGUMENTS & RETURN TYPE
FLOWCHART:
start

Read year yr

yr%4==0

Leap year

Not a leap year

stop

Thus the c program to check whether the given year is leap or not using functions was written, entered, executed and the output was verified.

EX: NO: 08 (b) FUNCTIONS WITHO UT ARGUM ENTS & WITH RETURN TYPE

FLOWCHART:
start

Read a,b,c

s=(a+b+c)/2

ar=sqrt(s*(s-a)*(s-b)*(s-c));

Print ar

stop

The Area of Triangle is 19.748418

RESULT: Thus the c program to calculate the area of triangle using functions was written, entered, executed and the output was verified

EX: NO: 08 (c) FUNCTIONS WITH ARGUMENTS & WITHOUT RETURN TYPE

FLOWCHART:
start

Read element n

Read array element

a[i]>a[j]

T=a[i]; a[i]=a[j]; a[j]=t;

Print total no. of elements

Print array elements one by one

Print array elements befor e sorting

Print array elements after sorting

stop

RESULT: Thus the c program to sort the given array of elements using functions was written, entered, executed and the output was verified.

EX: NO: 08 (d)FUNCTIONS WITH ARGUMENTS & RETURN TYPE

FLOWCHART:
start

Read element n

Read array element a[i]

s=a[i]

s=small(a,n)

Print smallest element of an array

stop

RESULT: Thus the c program to find the smallest element of given array of elements using functions was written, entered, executed and the output was verified.

EX: NO: 09 PROGRAM USING RECURSIVE FUNCTION (a)


FLOWCHART:
start

FACTORIAL OF A NUMBER

Read number n

n==0 || n==1

n*factorial(n-1)

Return 1

Print factorial for the number

stop

EX: NO: 09 (b)


FLOWCHART:
start

SUM OF DIGITS

Read number n

n<10

(n%10 )+s um(n/ 10,s );

Return n

s=sum(n,s);

Print the sum of digits

stop

RESULT: Thus the c program to find the sum of digits of a given number was written, entered, executed and the output was verified.

EX.NO:9(c)

RECURSIVE FUNCTIONS -FIBONACCI SERIES

FLOWCHART:
start

Read Fibonacci series limit

Fib(n) a=0 b=1

c=a+b; a=b; b=c;

Print Fibonacci series c

stop

RESULT: Thus the c program to find the recursive function of a Fibonacci serieswas written, entered, executed and the output was verified.

EX.NO:9(d) RECURSIVE FUNCTION-TO REVERSE A STRING

FLOWCHART:
start

Read string str

rev = getReverse(str);

*str

getReverse(str+1); rev[i++] = *str;

Print reversed string rev

stop

RESULT: Thus the c program to find the recursive function of reversing the given string was written, entered, executed and the output was verified.

EX:NO:10 PROGRAM USING STRUCTURES AND UNIONS (a) RECORD


FLOWCHART:
start

STUDENT

Read rollno,name,dept and marks rno,,name ,dept, m1,m2,m3

s.avg=(s.m1+s.m2+s.m3)/3;

Print rollno,name,deot,marks and average marks

stop

RESULT: Thus the c program to maintain the student record using structures was written, entered, executed and the output was verified.

EX:NO: 10 (b) STRUCTURES


FLOWCHART:

ARRAY OF

start

Read rollno,name,dept,marks rollno,name,marks,m1,m2,m3

s[i].rno==a

Print rollno,name,dept,marks

Read rollno to find details

stop

RESULT: Thus the c program to maintain various number of students record using array of structures was written, entered, executed and the output was verified.

EX: NO: 10 (c) PROGRAM FOR SIZE OF UNION

FLOWCHART:
start

Read book name,book price bname,price

Print the bool details

stop

RESULT:
Thus the c program to store the book information using union was written,

entered, executed and the output was verified.

S-ar putea să vă placă și