a) AIM: Write a c program to find the sum of individual digits of the given positive integer Start Sum = 0 Read n value While(n>0)

Size: px
Start display at page:

Download "a) AIM: Write a c program to find the sum of individual digits of the given positive integer Start Sum = 0 Read n value While(n>0)"

Transcription

1 Regulation R10 C PROGRAMMING LAB MANUAL EXERCISE-1: a) AIM: Write a c program to find the sum of individual digits of the given positive integer ALGORITHM: Step 1: Start. Step 2: Take variables namely sum, n. Step 3: Read n value. Step 4: Initialize sum=0. Step 5: While(n>0) then sum=sum+(n%10); n=n/10; Step 6: Write sum of the digits. Step 7: Stop. FLOWCHART: Start Sum = 0 Read n value While(n>0) Sum=sum+(n%10) n = n/10 Write sum Stop Department of Computer Science & Engineering 1

2 PROGRAM: #include<stdio.h> #include<conio.h> void main() int sum=0,n; clrscr(); printf("enter any n value:"); scanf("%d",&n); while(n>0) sum=sum+(n%10); n=n/10; printf("sum of the digits of given number is:%d",sum); getch(); OUTPUT: Enter any n value: 783 Sum of the digits of given number is: 18 Department of Computer Science & Engineering 2

3 b) AIM: A Fibonacci series is defined as follows: the first and second terms in the sequence are 0 and 1. Subsequent terms are found by adding the preceding two terms in the sequence. Write a c program to generate the first n terms of the sequence. ALGORITHM: Step 1: Start. Step 2: Take variables namely n, i,t1, t2,t. Step 3: Initialize variables t1=0 and t2=1. Step 4: Read n value. Step 5: Display t1 and t2. Step 6: for i=1 to i<=n-2 then i++ t=t1+t2. Display t value. t1=t2. t2=t. Step 7: Stop. Department of Computer Science & Engineering 3

4 FLOWCHART: Start Read n value t1 =0 t2=1 Display t1 and t2 i = 1 i <=n-2 t = t1+t2 Display t value. Stop i++ t1 = t2 t2 = t Department of Computer Science & Engineering 4

5 PROGRAM: #include<stdio.h> #include<conio.h> void main() int n,t1=0,t2=1,t,i; clrscr(); printf("enter any n value:"); scanf("%d",&n); printf("fibonancci series is:"); printf("%5d%5d",t1,t2); for(i=1;i<=n-2;i++) t=t1+t2; printf("%5d",t); t1=t2; t2=t; getch(); OUTPUT: Enter any n value: 8 Fibonacci series is: Department of Computer Science & Engineering 5

6 c) AIM: Write a C program to generate all the prime numbers between 1 and n, where n is a value supplied by the user. ALGORITHM: Step 1: Start. Step 2: Take variables namely n,m,i,j,count. Step 3: Read n value. Step 4: for i=1 to i<=n then i++ count=0. Step 5: Stop. for j=1 to j<=i then j++ if(i%j==0) count++ if(count==2) Display i value. Department of Computer Science & Engineering 6

7 FLOWCHART: Start Read n value. i = 1 i <= n count = 0 j = 1 i ++ j <= i i%j= =0 count= =2 Stop count++ Display i j ++ Department of Computer Science & Engineering 7

8 PROGRAM: #include<stdio.h> #include<conio.h> void main() int n,count,i,j; clrscr(); printf("enter any n value:"); scanf("%d",&n); printf("prime numbers from 1 to %d are:",n); for(i=1;i<=n;i++) count=0; for(j=1;j<=i;j++) if(i%j==0) count++; if(count==2) printf("%5d",i); getch(); OUTPUT: Enter any n value: 15 Prime numbers from 1 to 15 are: Department of Computer Science & Engineering 8

9 WEEK-2: a) AIM: Write a C program to calculate the following Sum: Sum=1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10! ALGORITHM: Step 1: Start. Step 2: Take variables namely n,x,i,p; Step 3: Initialize p to 0 and sum to 0 Step 4: Read n and x values. Step 5: for i=1 to i<=n then i++ Step 6: if(i%2!=0) then sum=sum+pow(x,p)/fact(p) goto step9. Step 7: else sum=sum-pow(x,p)/fact(p) goto step9. p=p+2 step 8: Display the sum value. Step 9: fact(int x) if(x<=1) then Return 1 to step5 else Return x*fact(x-1) to step 5. Step 10: Stop. Department of Computer Science & Engineering 9

10 FLOWCHART: Start p=0 x=0 Read n,x values i=1 i<=n i%2!=0 sum=sum+pow(x,p)/fact(p) sum=sum-pow(x,p)/fact(p) Display sum x<1 Stop f= x*fact(x-1) return f p=p+2 i++ Department of Computer Science & Engineering 10

11 PROGRAM: #include<stdio.h> #include<conio.h> #include<math.h> unsigned long fact(int x) if(x<=1) return 1; else return x*fact(x-1); void main() int n,x,i,p=0; float sum=0; clrscr(); printf("enter numer of terms:"); scanf("%d",&n); printf("enter x value:"); scanf("%d",&x); for(i=1;i<=n;i++) if(i%2!=0) sum=sum+pow(x,p)/fact(p); else sum=sum-pow(x,p)/fact(p); p=p+2; printf("sum of given series is:%.2f",sum); getch(); OUTPUT: Enter numer of terms:4 Enter x value:1 Sum of given series is:0.54 Department of Computer Science & Engineering 11

12 b) AIM: Write a c program to find the roots of a quadratic equation. ALGORITHM: Step 1: Start. Step 2: Take variables namely a,b,c,x1,x2. Step 3: Read a,b and c values. Step 4: if b2-4ac<0 then s=abs(b*b-4*a*c) Find real part r=-b/(2*a) value Find imaginary part i=s/(2*a) Display the First root value is (r,i) Display the Second root value is(r,-i) else Find first root value x1=(-b+sqrt(b*b-4*a*c))/(2*a) Find the second root valuex2=(-b-sqrt(b*b-4*a*c))/(2*a) Display x1 and x2. Step 5: Stop. FLOWCHART: Start Read a and b values b2-4ac<0 S=abs(b*b-4*a*c) x1=(float)(-b+sqrt(b*b-(4*a*c)))/(2*a) r=-b/(2*a) X2=(float)(-b-sqrt(b*b-(4*a*c)))/(2*a) i=s/(2*a) Display (r,i) Display x1,x2 Display (r,-i) Stop Department of Computer Science & Engineering 12

13 PROGRAM: #include<stdio.h> #include<conio.h> #include<math.h> void main() int a,b,c; float x1,x2,s,r,i; clrscr(); printf("enter a,b and c values:"); scanf("%d%d%d",&a,&b,&c); if((b*b-4*a*c)<0) s=abs(b*b-4*a*c); r=-b/(2*a); i=s/(2*a); printf("first root value is:(%f,%f)",r,i); printf("\nsecond root value is:(%f,%f)",r,-i); else x1=(-b+sqrt(b*b-4*a*c))/(2*a); x2=(-b-sqrt(b*b-4*a*c))/(2*a); printf("\nfirst root value is:%f",x1); printf("\nsecond root value is:%f",x2); getch(); OUTPUT: Enter a,b and c values: First root value is: Second root value is: Department of Computer Science & Engineering 13

14 WEEK-3: a) AIM The total distance travelled by vehicle in t seconds is given by distance = ut+1/2at2 where u and a are the initial velocity (m/sec.) and acceleration (m/sec2). Write C program to find the distance travelled at regular intervals of time given the values of u and a. The program should provide the flexibility to the user to select his own time intervals and repeat the calculations for different values of u and a. ALGORITHM: Step 1: Start. Step 2: Take variables namely u, a, t and s. Step 3: Read u, a, and t. Step 4: s=u*t+ ½ *a*square(t) Step 5: Write s Step 6: Stop. FLOWCHART: Start Read u, a and t s=u*t+ ½ *a*square(t) display s Stop Department of Computer Science & Engineering 14

15 PROGRAM: #include<stdio.h> #include<conio.h> #include<math.h> void main() float u,a,t,dis; clrscr(); printf("enter initial velocity(u):"); scanf("%f",&u); printf("enter acceleration(a):"); scanf("%f",&a); printf("enter travelled time(t):"); scanf("%f",&t); dis=u*t+((float)1/2*a*pow(t,2)); printf("distance travelled is:%f",dis); getch(); OUTPUT: Enter initial velocity (u): 5 Enter acceleration (a): 2 Enter traveled time: 3 Distance traveled is: Department of Computer Science & Engineering 15

16 b) AIM: Write a C program, which takes two integer operands and one operator form the user, performs the operation and then prints the result. (Consider the operators +,-,*, /, % and use Switch Statement) ALGORITHM: Step 1: Start. Step 2: Take three variables namely a, b and opt. Step 3: Read a, b and opt. Step 4: Switch (opt) Case + then write a+b Case - then write a-b Case * then write a*b Case / then write a/b Case % then write a%b Default then invalid option Step 5: Stop. Department of Computer Science & Engineering 16

17 FLOWCHART: Start Read a, b and opt Case + Case - Case * Case / Case % Write a+b Write a-b Write a*b Write a/b Write a%b Invalid option Stop Department of Computer Science & Engineering 17

18 PROGRAM: #include<stdio.h> #include<conio.h> void main() int a,b; char opt; clrscr(); printf("enter a and b values:"); scanf("%d%d",&a,&b); printf("enter any option:"); flushall(); scanf("%c",&opt); switch(opt) case '+': case '-': case '*': case '/': case '%': default: getch(); printf("addition of given two values is:%d",a+b); break; printf("subtraction of given two values is:%d",a-b); break; printf("multiplication of given two values is:%d",a*b); break; printf("division of given two values is:%d",a/b); break; printf("modulus of given two values is:%d",a%b); break; printf("invalid option"); OUTPUT: Enter a and b values: 10 5 Enter any option: + Addition of given two values is: 15 Department of Computer Science & Engineering 18

19 WEEK-3: i) AIM: Write a c program to find the factorial of given number using recursive function ALGORITHM: Step 1: Start. Step 2: Take variables namely n,f. Step 3: Read n value. Step 4: f=fact(n) Step 5: if(n<=1) then Step 6: return 1 to step4 Step 7: else return x*fact(x-1) to step 4. Step 8: Display f value. Step 9: Stop Start FLOWCHART: Read n f=fact(n) return 1 return x*fact(x-1) Display f n<=1 Stop PROGRAM: #include<stdio.h> #include<conio.h> void main() unsigned long fact(int); int n; unsigned long f; clrscr(); printf("enter any n value:"); scanf("%d",&n); f=fact(n); printf("factorial of given value is:%lu",f); getch(); unsigned long fact(int n) OUTPUT Enter any n value:5 Factorial of given value is:120 if(n<=1) return 1; else return n*fact(n-1); Department of Computer Science & Engineering 19

20 i) AIM: Write a c program to find the factorial of given number using non-recursive function ALGORITHM: Step 1: Start. Step 2: Take variables namely n and f. Step 3: Read n value Step 4: f=factorial(n) Step 5: Take variable fa=1. Step 6: while(n>=1) then fa=fa*n n step 7: Return fa value to step 4 Step 8: Display f value Step 9: Stop FLOWCHART: Start Read n f=factorial(n) fa=1 return fa Display f n>=1 Stop fa=fa*n n-- PROGRAM: #include<stdio.h> #include<conio.h> void main() unsigned long factorial(int); int n; unsigned long f; clrscr(); printf("enter any n value:"); scanf("%d",&n); f=factorial(n); printf("factorial of given value is:%lu",f); getch(); Department of Computer Science & Engineering 20

21 unsigned long factorial(int n) unsigned long fa=1; while(n>=1) fa=fa*n; n--; return fa; OUTPUT Enter any n value:5 Factorial of given value is: 120 ii) AIM: Write a c program to find the GCD (greatest common divisor)of two given integers using non-recursive functions. ALGORITHM: Step 1: Start. Step 2: Take variables namely a,b and g. Step 3: Read two variables namely a,b Step 4: g=gcd(a,b) Step 5: Take vraibles namely m, i and gc Step 6: m=(a>b)?a:b; Step 7: for i=1 to i<=m then i++ if(a%i==0 and b%i==0) then gc=i. step 8: return gc to step 3 step 9: Display g value Step 10: Stop. Department of Computer Science & Engineering 21

22 FLOWCHART: Start Read a and b values g=gcd(a,b) m=(a>b)?a:b for(i=1;i<=m;i++) Display g value if(a%i==0)&& (b%i==0) Stop g = i PROGRAM: #include<stdio.h> #include<conio.h> void main() int gcd(int,int); int a,b,g; clrscr(); printf("enter any two values:"); scanf("%d%d",&a,&b); g=gcd(a,b); printf("g.c.d of given two values is:%d",g); getch(); Department of Computer Science & Engineering 22

23 int gcd(int a,int b) int i,m,gc; m=(a<b)?a:b; for(i=1;i<=m;i++) if(a%i==0&&b%i==0) gc=i; return gc; OUTPUT: Enter any two values: 4 8 G.C.D of given two values is: 4 ii) AIM: Write a c program to find the GCD (greatest common divisor)of two given integers using recursive functions. ALGORITHM: Step 1: Start Step 2: Take variables namely a,b and g. Step 3: Read a and b values Step 4: g=gcd(a,b) Step 5: Take variables namely m,i=1,g Step 6: find minimum among a and b m=(a>b)?a:b step 7: if(a%i==0&&b%i==0) g=i step 8: i++ step 9: if(i<=m) goto step 4 step 10: return g value to step4 step 11: Display g value step 12: Stop. Department of Computer Science & Engineering 23

24 FLOWCHART: Start Read a and b values g=gcd(a,b) m=(a>b)?a:b for(i=1;i<=m;i++) Display g value if(a%i==0)&& (b%i==0) Stop g = i PROGRAM: #include<stdio.h> #include<conio.h> void main() int gcd(int,int); int a,b,g; clrscr(); printf("enter any two values:"); scanf("%d%d",&a,&b); g=gcd(a,b); printf("g.c.d of given two values is:%d",g); getch(); int gcd(int a,int b) static int m,i=1,g; m=(a<b)?a:b; if(a%i==0&&b%i==0) g=i; OUTPUT: i++; Enter any two values: 4 8 if(i<=m) G.C.D of given two values is: 4 gcd(a,b); return g; Department of Computer Science & Engineering 24

25 WEEK 8 a) AIM: Write a program to generate Pascal s triangle. ALGORITHM: Step 1: Start. Step 2: Take variables namely n, i,j,s,ncr. Step 3: Read n value. Step 4: s=n*3. Step 5: for i=0 to i<=n then i++ Display s spaces. for j=0 to j<=i then j++ ncr=fact(i)/fact(j)*fact(i-j). Display ncr. s=s-3. Display \n Step 6: Stop. FLOWCHART: Start Read n value s = n*3 for i=0 to i<=n ;i++ Display s spaces for j=0 to j<=i ;j++ ncr=fact(i)/fact(j)*fact(i-j) Display ncr s=s-3 Display \n Stop Department of Computer Science & Engineering 25

26 PROGRAM: #include<stdio.h> #include<conio.h> unsigned long fact(int x) if(x<=1) return 1; else return x*fact(x-1); void main() int n,i,j,s,ncr; clrscr(); printf("enter any n value:"); scanf("%d",&n); s=n*3; for(i=0;i<=n;i++) printf("%*c",s,32); for(j=0;j<=i;j++) ncr=fact(i)/(fact(j)*fact(i-j)); printf("%5d",ncr); s=s-3; printf("\n"); getch(); OUTPUT: Enter any n value: Department of Computer Science & Engineering 26

27 b) AIM: Write a c program to construct a pyramid of numbers ALGORITHM: Step 1: Start. Step 2: Take variables namely i, j, m, n,s. Step 3: Read n value. Step 4: s=n*4. Step 5: for i=1 to i<=n then i Display s spaces. 5.2 m=i. 5.3 for j=1 to j<2*i then j if(j<i) then Display m++ value else then Display m-- value 5.4 Display \n. 5.5 s=s-4. Step 6: Stop. Department of Computer Science & Engineering 27

28 FLOWCHART: Start Read n value s=n*4 for i=1 to i<=n i++ Display s spaces m=i Display m-- for j=1 to j<=i i++ if(j<i) Display m++ Display \n s=s-4 Stop Department of Computer Science & Engineering 28

29 PROGRAM: #include<stdio.h> #include<conio.h> void main() int i,m,j,n,s; clrscr(); printf("enter any n value:"); scanf("%d",&n); s= n*4; for(i=1;i<=n;i++) printf("%*c",s,32); m=i; for(j=1;j<2* i;j++) if(j<i) else printf("\n\n"); s=s-4; getch(); OUTPUT: Enter any n value: printf("%4d",m++); printf( %4d,m--); Department of Computer Science & Engineering 29

30 WEEK 9 AIM: Write a C function to read in two numbers, x and n, and then compute the sum of this geometric progression: 1+x+x2+x3+.+xn ALGORITHM: Step 1: Start Step 2: Take variables namely n,i,x,sum=0 Step 3: Read n value Step 4: if(n<0) Display number of terms must be a positive value Goto Step Step 5: Read x value Step 6: for(i=0;i<=n;i++) Sum=sum+power(x,i) Step 7: Display the sum value Step 8: Stop FLOWCHART: Start sum=0 Read n value if(n<0) n must be positive Read x value for(i=0;i<=n;i++) Display sum sum=sum+pow(x,i) Stop Department of Computer Science & Engineering 30

31 PROGRAM: #include<stdio.h> #include<conio.h> #include<math.h> void main() int n,i; float x,sum=0; clrscr(); lb: printf("\nenter number of terms value:"); scanf("%d",&n); if(n<0) printf("number of terms value must be positive"); goto lb; printf("enter any x value:"); scanf("%f",&x); for(i=0;i<=n;i++) sum=sum+pow(x,i); printf("sum of the given series is:%.2f",sum); getch(); OUTPUT: Enter number of terms value: 5 Enter any x value: 1 Sum of the given series is: 6.00 Department of Computer Science & Engineering 31

OS Lab Manual. To provide an understanding of the design aspects of operating system. Recommended Systems/Software Requirements:

OS Lab Manual. To provide an understanding of the design aspects of operating system. Recommended Systems/Software Requirements: OS Lab Manual Objective: To provide an understanding of the design aspects of operating system. Recommended Systems/Software Requirements: Intel based desktop PC with minimum of 166 MHZ or faster processor

More information

Computer Science 2nd Year Solved Exercise. Programs 3/4/2013. Aumir Shabbir Pakistan School & College Muscat. Important. Chapter # 3.

Computer Science 2nd Year Solved Exercise. Programs 3/4/2013. Aumir Shabbir Pakistan School & College Muscat. Important. Chapter # 3. 2013 Computer Science 2nd Year Solved Exercise Chapter # 3 Programs Chapter # 4 Chapter # 5 Chapter # 6 Chapter # 7 Important Work Sheets Aumir Shabbir Pakistan School & College Muscat 3/4/2013 Chap #

More information

Functions Recursion. C++ functions. Declare/prototype. Define. Call. int myfunction (int ); int myfunction (int x){ int y = x*x; return y; }

Functions Recursion. C++ functions. Declare/prototype. Define. Call. int myfunction (int ); int myfunction (int x){ int y = x*x; return y; } Functions Recursion C++ functions Declare/prototype int myfunction (int ); Define int myfunction (int x){ int y = x*x; return y; Call int a; a = myfunction (7); function call flow types type of function

More information

TYPICAL QUESTIONS & ANSWERS

TYPICAL QUESTIONS & ANSWERS PART - I, TYPICAL QUESTIONS & ANSWERS OBJECTIVE TYPE QUESTIONS Each Question carries 2 marks. Choose correct or the best alternative in the following: Q.1 Literal means (A) a string. (C) a character. Ans:B

More information

The input consists of a sequence of integer pairs n and p with each integer on a line by. itself. For all such pairs, and there exists an integer k,

The input consists of a sequence of integer pairs n and p with each integer on a line by. itself. For all such pairs, and there exists an integer k, APPENDIX A ACM PROGRAMMING PROBLEMS 183 The Input The input consists of a sequence of integer pairs n and p with each integer on a line by itself. For all such pairs, and there exists an integer k, such

More information

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements 9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending

More information

What Is Recursion? Recursion. Binary search example postponed to end of lecture

What Is Recursion? Recursion. Binary search example postponed to end of lecture Recursion Binary search example postponed to end of lecture What Is Recursion? Recursive call A method call in which the method being called is the same as the one making the call Direct recursion Recursion

More information

Recursive Algorithms. Recursion. Motivating Example Factorial Recall the factorial function. { 1 if n = 1 n! = n (n 1)! if n > 1

Recursive Algorithms. Recursion. Motivating Example Factorial Recall the factorial function. { 1 if n = 1 n! = n (n 1)! if n > 1 Recursion Slides by Christopher M Bourke Instructor: Berthe Y Choueiry Fall 007 Computer Science & Engineering 35 Introduction to Discrete Mathematics Sections 71-7 of Rosen cse35@cseunledu Recursive Algorithms

More information

Unit 1. 5. Write iterative and recursive C functions to find the greatest common divisor of two integers. [6]

Unit 1. 5. Write iterative and recursive C functions to find the greatest common divisor of two integers. [6] Unit 1 1. Write the following statements in C : [4] Print the address of a float variable P. Declare and initialize an array to four characters a,b,c,d. 2. Declare a pointer to a function f which accepts

More information

C Programming. Charudatt Kadolkar. IIT Guwahati. C Programming p.1/34

C Programming. Charudatt Kadolkar. IIT Guwahati. C Programming p.1/34 C Programming Charudatt Kadolkar IIT Guwahati C Programming p.1/34 We want to print a table of sine function. The output should look like: 0 0.0000 20 0.3420 40 0.6428 60 0.8660 80 0.9848 100 0.9848 120

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void 1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of

More information

COMPUTER SCIENCE. Paper 1 (THEORY)

COMPUTER SCIENCE. Paper 1 (THEORY) COMPUTER SCIENCE Paper 1 (THEORY) (Three hours) Maximum Marks: 70 (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time) -----------------------------------------------------------------------------------------------------------------------

More information

USE OF HYPERVIDEO FOR TEACHING C/C++ Luiz-Alberto Vieira-Dias Andre Catoto-Dias

USE OF HYPERVIDEO FOR TEACHING C/C++ Luiz-Alberto Vieira-Dias Andre Catoto-Dias USE OF HYPERVIDEO FOR TEACHING C/C++ Luiz-Alberto Vieira-Dias Andre Catoto-Dias UNIVAP-Paraiba Valley University School of Computer Science São Jose dos Campos, SP, Brazil vdias@univap.br ABSTRACT This

More information

Cryptography and Network Security Number Theory

Cryptography and Network Security Number Theory Cryptography and Network Security Number Theory Xiang-Yang Li Introduction to Number Theory Divisors b a if a=mb for an integer m b a and c b then c a b g and b h then b (mg+nh) for any int. m,n Prime

More information

Phys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions

Phys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions Phys4051: C Lecture 2 & 3 Functions (Review) Comment Statements Variables & Operators Branching Instructions Comment Statements! Method 1: /* */! Method 2: // /* Single Line */ //Single Line /* This comment

More information

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T) Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

More information

Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Introduction to Programming (in C++) Loops Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Example Assume the following specification: Input: read a number N > 0 Output:

More information

Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:

Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification: Example Introduction to Programming (in C++) Loops Assume the following specification: Input: read a number N > 0 Output: write the sequence 1 2 3 N (one number per line) Jordi Cortadella, Ricard Gavaldà,

More information

Data Structure with C

Data Structure with C Subject: Data Structure with C Topic : Tree Tree A tree is a set of nodes that either:is empty or has a designated node, called the root, from which hierarchically descend zero or more subtrees, which

More information

Section 6.1 Factoring Expressions

Section 6.1 Factoring Expressions Section 6.1 Factoring Expressions The first method we will discuss, in solving polynomial equations, is the method of FACTORING. Before we jump into this process, you need to have some concept of what

More information

CpSc212 Goddard Notes Chapter 6. Yet More on Classes. We discuss the problems of comparing, copying, passing, outputting, and destructing

CpSc212 Goddard Notes Chapter 6. Yet More on Classes. We discuss the problems of comparing, copying, passing, outputting, and destructing CpSc212 Goddard Notes Chapter 6 Yet More on Classes We discuss the problems of comparing, copying, passing, outputting, and destructing objects. 6.1 Object Storage, Allocation and Destructors Some objects

More information

Chapter 5. Recursion. Data Structures and Algorithms in Java

Chapter 5. Recursion. Data Structures and Algorithms in Java Chapter 5 Recursion Data Structures and Algorithms in Java Objectives Discuss the following topics: Recursive Definitions Method Calls and Recursion Implementation Anatomy of a Recursive Call Tail Recursion

More information

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE PROGRAMMING IN C CONTENT AT A GLANCE 1 MODULE 1 Unit 1 : Basics of Programming Unit 2 : Fundamentals Unit 3 : C Operators MODULE 2 unit 1 : Input Output Statements unit 2 : Control Structures unit 3 :

More information

Keywords: Dynamic pricing, Hotel room forecasting, Monte Carlo simulation, Price Elasticity, Revenue Management System

Keywords: Dynamic pricing, Hotel room forecasting, Monte Carlo simulation, Price Elasticity, Revenue Management System Volume 3, Issue 5, May 2013 ISSN: 2277 128X International Journal of Advanced Research in Computer Science and Software Engineering Research Paper Available online at: www.ijarcsse.com Dynamic Pricing

More information

Adaptive Stable Additive Methods for Linear Algebraic Calculations

Adaptive Stable Additive Methods for Linear Algebraic Calculations Adaptive Stable Additive Methods for Linear Algebraic Calculations József Smidla, Péter Tar, István Maros University of Pannonia Veszprém, Hungary 4 th of July 204. / 2 József Smidla, Péter Tar, István

More information

I PUC - Computer Science. Practical s Syllabus. Contents

I PUC - Computer Science. Practical s Syllabus. Contents I PUC - Computer Science Practical s Syllabus Contents Topics 1 Overview Of a Computer 1.1 Introduction 1.2 Functional Components of a computer (Working of each unit) 1.3 Evolution Of Computers 1.4 Generations

More information

CS 103X: Discrete Structures Homework Assignment 3 Solutions

CS 103X: Discrete Structures Homework Assignment 3 Solutions CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering

More information

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java

More information

Example of a Java program

Example of a Java program Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);

More information

Intermediate Math Circles March 7, 2012 Linear Diophantine Equations II

Intermediate Math Circles March 7, 2012 Linear Diophantine Equations II Intermediate Math Circles March 7, 2012 Linear Diophantine Equations II Last week: How to find one solution to a linear Diophantine equation This week: How to find all solutions to a linear Diophantine

More information

FPGA Implementation of an Extended Binary GCD Algorithm for Systolic Reduction of Rational Numbers

FPGA Implementation of an Extended Binary GCD Algorithm for Systolic Reduction of Rational Numbers FPGA Implementation of an Extended Binary GCD Algorithm for Systolic Reduction of Rational Numbers Bogdan Mătăsaru and Tudor Jebelean RISC-Linz, A 4040 Linz, Austria email: bmatasar@risc.uni-linz.ac.at

More information

Factoring Algorithms

Factoring Algorithms Factoring Algorithms The p 1 Method and Quadratic Sieve November 17, 2008 () Factoring Algorithms November 17, 2008 1 / 12 Fermat s factoring method Fermat made the observation that if n has two factors

More information

Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators

Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators Conditional Statements For computer to make decisions, must be able to test CONDITIONS IF it is raining THEN I will not go outside IF Count is not zero THEN the Average is Sum divided by Count Conditions

More information

EAP/GWL Rev. 1/2011 Page 1 of 5. Factoring a polynomial is the process of writing it as the product of two or more polynomial factors.

EAP/GWL Rev. 1/2011 Page 1 of 5. Factoring a polynomial is the process of writing it as the product of two or more polynomial factors. EAP/GWL Rev. 1/2011 Page 1 of 5 Factoring a polynomial is the process of writing it as the product of two or more polynomial factors. Example: Set the factors of a polynomial equation (as opposed to an

More information

( ) ( ) Math 0310 Final Exam Review. # Problem Section Answer. 1. Factor completely: 2. 2. Factor completely: 3. Factor completely:

( ) ( ) Math 0310 Final Exam Review. # Problem Section Answer. 1. Factor completely: 2. 2. Factor completely: 3. Factor completely: Math 00 Final Eam Review # Problem Section Answer. Factor completely: 6y+. ( y+ ). Factor completely: y+ + y+ ( ) ( ). ( + )( y+ ). Factor completely: a b 6ay + by. ( a b)( y). Factor completely: 6. (

More information

Introduction. Earlier programs structured as methods that call one another in a disciplined, hierarchical manner Recursive methods

Introduction. Earlier programs structured as methods that call one another in a disciplined, hierarchical manner Recursive methods Recursion 1 2 Introduction Earlier programs structured as methods that call one another in a disciplined, hierarchical manner Recursive methods Call themselves Useful for some problems to define a method

More information

Recursion and Dynamic Programming. Biostatistics 615/815 Lecture 5

Recursion and Dynamic Programming. Biostatistics 615/815 Lecture 5 Recursion and Dynamic Programming Biostatistics 615/815 Lecture 5 Last Lecture Principles for analysis of algorithms Empirical Analysis Theoretical Analysis Common relationships between inputs and running

More information

Definitions 1. A factor of integer is an integer that will divide the given integer evenly (with no remainder).

Definitions 1. A factor of integer is an integer that will divide the given integer evenly (with no remainder). Math 50, Chapter 8 (Page 1 of 20) 8.1 Common Factors Definitions 1. A factor of integer is an integer that will divide the given integer evenly (with no remainder). Find all the factors of a. 44 b. 32

More information

The Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)!

The Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)! The Tower of Hanoi Recursion Solution recursion recursion recursion Recursive Thinking: ignore everything but the bottom disk. 1 2 Recursive Function Time Complexity Hanoi (n, src, dest, temp): If (n >

More information

16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution

16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution 16. Recursion COMP 110 Prasun Dewan 1 Loops are one mechanism for making a program execute a statement a variable number of times. Recursion offers an alternative mechanism, considered by many to be more

More information

Two-way selection. Branching and Looping

Two-way selection. Branching and Looping Control Structures: are those statements that decide the order in which individual statements or instructions of a program are executed or evaluated. Control Structures are broadly classified into: 1.

More information

ALGORITHMS AND FLOWCHARTS. By Miss Reham Tufail

ALGORITHMS AND FLOWCHARTS. By Miss Reham Tufail ALGORITHMS AND FLOWCHARTS By Miss Reham Tufail ALGORITHMS AND FLOWCHARTS A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that describe

More information

MATHCOUNTS TOOLBOX Facts, Formulas and Tricks

MATHCOUNTS TOOLBOX Facts, Formulas and Tricks MATHCOUNTS TOOLBOX Facts, Formulas and Tricks MATHCOUNTS Coaching Kit 40 I. PRIME NUMBERS from 1 through 100 (1 is not prime!) 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 II.

More information

3/13/2012. Writing Simple C Programs. ESc101: Decision making using if-else and switch statements. Writing Simple C Programs

3/13/2012. Writing Simple C Programs. ESc101: Decision making using if-else and switch statements. Writing Simple C Programs Writing Simple C Programs ESc101: Decision making using if- and switch statements Instructor: Krithika Venkataramani Semester 2, 2011-2012 Use standard files having predefined instructions stdio.h: has

More information

Section IV.1: Recursive Algorithms and Recursion Trees

Section IV.1: Recursive Algorithms and Recursion Trees Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

8 Divisibility and prime numbers

8 Divisibility and prime numbers 8 Divisibility and prime numbers 8.1 Divisibility In this short section we extend the concept of a multiple from the natural numbers to the integers. We also summarize several other terms that express

More information

Java Program Coding Standards 4002-217-9 Programming for Information Technology

Java Program Coding Standards 4002-217-9 Programming for Information Technology Java Program Coding Standards 4002-217-9 Programming for Information Technology Coding Standards: You are expected to follow the standards listed in this document when producing code for this class. Whether

More information

12-6 Write a recursive definition of a valid Java identifier (see chapter 2).

12-6 Write a recursive definition of a valid Java identifier (see chapter 2). CHAPTER 12 Recursion Recursion is a powerful programming technique that is often difficult for students to understand. The challenge is explaining recursion in a way that is already natural to the student.

More information

COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms.

COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms. COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms 1 Activation Records activation declaration location Recall that an activation

More information

Finding Solutions of Polynomial Equations

Finding Solutions of Polynomial Equations DETAILED SOLUTIONS AND CONCEPTS - POLYNOMIAL EQUATIONS Prepared by Ingrid Stewart, Ph.D., College of Southern Nevada Please Send Questions and Comments to ingrid.stewart@csn.edu. Thank you! PLEASE NOTE

More information

Computer and Network Security

Computer and Network Security MIT 6.857 Computer and Networ Security Class Notes 1 File: http://theory.lcs.mit.edu/ rivest/notes/notes.pdf Revision: December 2, 2002 Computer and Networ Security MIT 6.857 Class Notes by Ronald L. Rivest

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

Assignment No.3. /*-- Program for addition of two numbers using C++ --*/

Assignment No.3. /*-- Program for addition of two numbers using C++ --*/ Assignment No.3 /*-- Program for addition of two numbers using C++ --*/ #include class add private: int a,b,c; public: void getdata() couta; cout

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015 CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Linda Shapiro Today Registration should be done. Homework 1 due 11:59 pm next Wednesday, January 14 Review math essential

More information

Output: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

Output: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr; 50 20 70 10 30 69 90 14 35 68 85 98 16 22 60 34 (c) Execute the algorithm shown below using the tree shown above. Show the exact output produced by the algorithm. Assume that the initial call is: prob3(root)

More information

Pemrograman Dasar. Basic Elements Of Java

Pemrograman Dasar. Basic Elements Of Java Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle

More information

6.1 Add & Subtract Polynomial Expression & Functions

6.1 Add & Subtract Polynomial Expression & Functions 6.1 Add & Subtract Polynomial Expression & Functions Objectives 1. Know the meaning of the words term, monomial, binomial, trinomial, polynomial, degree, coefficient, like terms, polynomial funciton, quardrtic

More information

OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES CONSTRUCTORS AND DESTRUCTORS

OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES CONSTRUCTORS AND DESTRUCTORS CONSTRUCTORS AND DESTRUCTORS Constructors: A constructor is a member function whose name is same as class name and is used to initialize data members and allocate memory dynamically. A constructor is automatically

More information

Recursion. Definition: o A procedure or function that calls itself, directly or indirectly, is said to be recursive.

Recursion. Definition: o A procedure or function that calls itself, directly or indirectly, is said to be recursive. Recursion Definition: o A procedure or function that calls itself, directly or indirectly, is said to be recursive. Why recursion? o For many problems, the recursion solution is more natural than the alternative

More information

SECTION 10-5 Multiplication Principle, Permutations, and Combinations

SECTION 10-5 Multiplication Principle, Permutations, and Combinations 10-5 Multiplication Principle, Permutations, and Combinations 761 54. Can you guess what the next two rows in Pascal s triangle, shown at right, are? Compare the numbers in the triangle with the binomial

More information

(!' ) "' # "*# "!(!' +,

(!' ) ' # *# !(!' +, Normally, when single line commands are entered, MATLAB processes the commands immediately and displays the results. MATLAB is also capable of processing a sequence of commands that are stored in files

More information

Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the ISA. RISC Goals RISC: Simplify ISA Simplify CPU Design Better CPU Performance Motivated by simplifying

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority) Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the

More information

LIC MANAGEMENT SYSTEM

LIC MANAGEMENT SYSTEM LIC MANAGEMENT SYSTEM C++ PROJECT REPORT M.S.Ramaiah Institute of Technology Dept. of Electronics and Instrumentation Engineering Submitted to: S.Elavaar Kuzhali Assistant Professor Submitted By: Pushkarini.R.K

More information

5: Magnitude 6: Convert to Polar 7: Convert to Rectangular

5: Magnitude 6: Convert to Polar 7: Convert to Rectangular TI-NSPIRE CALCULATOR MENUS 1: Tools > 1: Define 2: Recall Definition --------------- 3: Delete Variable 4: Clear a-z 5: Clear History --------------- 6: Insert Comment 2: Number > 1: Convert to Decimal

More information

OPTIMAL BINARY SEARCH TREES

OPTIMAL BINARY SEARCH TREES OPTIMAL BINARY SEARCH TREES 1. PREPARATION BEFORE LAB DATA STRUCTURES An optimal binary search tree is a binary search tree for which the nodes are arranged on levels such that the tree cost is minimum.

More information

Introduction to Computer Programming, Spring Term 2014 Practice Assignment 3 Discussion 15.3.2014-20.3.2014

Introduction to Computer Programming, Spring Term 2014 Practice Assignment 3 Discussion 15.3.2014-20.3.2014 German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Ahmed Gamal Introduction to Computer Programming, Spring Term 2014 Practice Assignment 3 Discussion 15.3.2014-20.3.2014

More information

CS 241 Data Organization Coding Standards

CS 241 Data Organization Coding Standards CS 241 Data Organization Coding Standards Brooke Chenoweth University of New Mexico Spring 2016 CS-241 Coding Standards All projects and labs must follow the great and hallowed CS-241 coding standards.

More information

Chapter 8 Selection 8-1

Chapter 8 Selection 8-1 Chapter 8 Selection 8-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow

More information

Catalan Numbers. Thomas A. Dowling, Department of Mathematics, Ohio State Uni- versity.

Catalan Numbers. Thomas A. Dowling, Department of Mathematics, Ohio State Uni- versity. 7 Catalan Numbers Thomas A. Dowling, Department of Mathematics, Ohio State Uni- Author: versity. Prerequisites: The prerequisites for this chapter are recursive definitions, basic counting principles,

More information

The C Programming Language

The C Programming Language Chapter 1 The C Programming Language In this chapter we will learn how to write simple computer programs using the C programming language; perform basic mathematical calculations; manage data stored in

More information

8 Primes and Modular Arithmetic

8 Primes and Modular Arithmetic 8 Primes and Modular Arithmetic 8.1 Primes and Factors Over two millennia ago already, people all over the world were considering the properties of numbers. One of the simplest concepts is prime numbers.

More information

The Ideal Class Group

The Ideal Class Group Chapter 5 The Ideal Class Group We will use Minkowski theory, which belongs to the general area of geometry of numbers, to gain insight into the ideal class group of a number field. We have already mentioned

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

More information

13. Write the decimal approximation of 9,000,001 9,000,000, rounded to three significant

13. Write the decimal approximation of 9,000,001 9,000,000, rounded to three significant æ If 3 + 4 = x, then x = 2 gold bar is a rectangular solid measuring 2 3 4 It is melted down, and three equal cubes are constructed from this gold What is the length of a side of each cube? 3 What is the

More information

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement? 1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members

More information

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved. 1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays

More information

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek Instruction Set Architecture or How to talk to computers if you aren t in Star Trek The Instruction Set Architecture Application Compiler Instr. Set Proc. Operating System I/O system Instruction Set Architecture

More information

Computer Programming Lecturer: Dr. Laith Abdullah Mohammed

Computer Programming Lecturer: Dr. Laith Abdullah Mohammed Algorithm: A step-by-step procedure for solving a problem in a finite amount of time. Algorithms can be represented using Flow Charts. CHARACTERISTICS OF AN ALGORITHM: Computer Programming Lecturer: Dr.

More information

Mathematics Pre-Test Sample Questions A. { 11, 7} B. { 7,0,7} C. { 7, 7} D. { 11, 11}

Mathematics Pre-Test Sample Questions A. { 11, 7} B. { 7,0,7} C. { 7, 7} D. { 11, 11} Mathematics Pre-Test Sample Questions 1. Which of the following sets is closed under division? I. {½, 1,, 4} II. {-1, 1} III. {-1, 0, 1} A. I only B. II only C. III only D. I and II. Which of the following

More information

SECTION 1-6 Quadratic Equations and Applications

SECTION 1-6 Quadratic Equations and Applications 58 Equations and Inequalities Supply the reasons in the proofs for the theorems stated in Problems 65 and 66. 65. Theorem: The complex numbers are commutative under addition. Proof: Let a bi and c di be

More information

This unit will lay the groundwork for later units where the students will extend this knowledge to quadratic and exponential functions.

This unit will lay the groundwork for later units where the students will extend this knowledge to quadratic and exponential functions. Algebra I Overview View unit yearlong overview here Many of the concepts presented in Algebra I are progressions of concepts that were introduced in grades 6 through 8. The content presented in this course

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

2010 Solutions. a + b. a + b 1. (a + b)2 + (b a) 2. (b2 + a 2 ) 2 (a 2 b 2 ) 2

2010 Solutions. a + b. a + b 1. (a + b)2 + (b a) 2. (b2 + a 2 ) 2 (a 2 b 2 ) 2 00 Problem If a and b are nonzero real numbers such that a b, compute the value of the expression ( ) ( b a + a a + b b b a + b a ) ( + ) a b b a + b a +. b a a b Answer: 8. Solution: Let s simplify the

More information

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The

More information

ALGEBRA 2/TRIGONOMETRY

ALGEBRA 2/TRIGONOMETRY ALGEBRA /TRIGONOMETRY The University of the State of New York REGENTS HIGH SCHOOL EXAMINATION ALGEBRA /TRIGONOMETRY Thursday, January 9, 015 9:15 a.m to 1:15 p.m., only Student Name: School Name: The possession

More information

3.5 RECURSIVE ALGORITHMS

3.5 RECURSIVE ALGORITHMS Section 3.5 Recursive Algorithms 3.5.1 3.5 RECURSIVE ALGORITHMS review : An algorithm is a computational representation of a function. Remark: Although it is often easier to write a correct recursive algorithm

More information

Factoring Polynomials and Solving Quadratic Equations

Factoring Polynomials and Solving Quadratic Equations Factoring Polynomials and Solving Quadratic Equations Math Tutorial Lab Special Topic Factoring Factoring Binomials Remember that a binomial is just a polynomial with two terms. Some examples include 2x+3

More information

PowerScore Test Preparation (800) 545-1750

PowerScore Test Preparation (800) 545-1750 Question 1 Test 1, Second QR Section (version 2) Two triangles QA: x QB: y Geometry: Triangles Answer: Quantity A is greater 1. The astute student might recognize the 0:60:90 and 45:45:90 triangle right

More information

Polynomial Degree and Finite Differences

Polynomial Degree and Finite Differences CONDENSED LESSON 7.1 Polynomial Degree and Finite Differences In this lesson you will learn the terminology associated with polynomials use the finite differences method to determine the degree of a polynomial

More information

Habanero Extreme Scale Software Research Project

Habanero Extreme Scale Software Research Project Habanero Extreme Scale Software Research Project Comp215: Java Method Dispatch Zoran Budimlić (Rice University) Always remember that you are absolutely unique. Just like everyone else. - Margaret Mead

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

Spare Parts Inventory Model for Auto Mobile Sector Using Genetic Algorithm

Spare Parts Inventory Model for Auto Mobile Sector Using Genetic Algorithm Parts Inventory Model for Auto Mobile Sector Using Genetic Algorithm S. Godwin Barnabas, I. Ambrose Edward, and S.Thandeeswaran Abstract In this paper the objective is to determine the optimal allocation

More information