mfinal

37
MRIDUL 291/COE/14 COE 2 INTRODUCTION TO PROGRAMMING

Upload: vaunagarwal

Post on 09-Nov-2015

214 views

Category:

Documents


0 download

DESCRIPTION

mFINAL

TRANSCRIPT

S.No.Title Of The ProgramDatePage No.Remarks

1.Program to find the sum of digits of an integer

2.Program to find GCD and LCM of two numbers

3.To find sum of n integers using array

4.Program to compute the value of sinx using exponential series

5.A program that takes coefficients of a quadratic equation as input and outputs the roots of the quadratic equation.

6.To find the factorial of any integer.

7.Program to make a calculator.

8.Write a program to find the greatest amongst three numbers.

9.To find the multiplication of digits of any integer.

10.To find sum of n integers using array

11.To sort n integers in ascending and descending order.

12.To find the average, sum and standard deviation for n numbers.

13.To print the multiplication table from 1 to 10.

14.To find addition of two matrices

15.To find subtraction of two matrices

16.To find multiplication of two matrices

17.To find the factorial of a number by recursion.

18.Write a program to find the nth Fibonacci number using recursion.

19.Program using recursion to find the sum of digits of any integer.

Q1.Program to find the sum of digits of an integer.

FLOWCHART

SOURCE CODE

#includeint main(){int a,sum=0; printf(Enter an integer);scanf(%d,&a);while(a>0){sum+=a%10;a/=10;}printf(Sum of digits of integer is %d.,sum);return 0;}

OUTPUT

Q2. Program to find GCD and LCM of two numbers.#include #include int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int main(){ int x,y,lcm,g; printf("Enter two numbers."); scanf("%d %d",&x,&y); g=gcd(x,y); printf("GCD=%d\n",g); lcm=x*y/g; printf("LCM=%d",lcm);

return 0;} OUTPUT

Q3.Program to find the greatest among three numbers.

FLOWCHART

SOURCE CODE

#includeint main(){int a,b,c,max;printf(Enter three integers:);scanf(%d%d%d,&a,&b,&c);max=a;if(max