Computer Science 2nd Year Solved Exercise. Programs 3/4/2013. Aumir Shabbir Pakistan School & College Muscat. Important. Chapter # 3.
|
|
|
- Veronica Armstrong
- 10 years ago
- Views:
Transcription
1 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
2 Chap # 3 Q#1. Write a program to find the sum of positive odd numbers and the product of positive even numbers less than or equal to 30. void main(void) int p,i,j,sum=0; while(j<=30) p=i*j; sum+=p; i=i+2; j=j+2; printf("the sum is equal to %d",sum); Q#2. Write a program that reads an integer and prints its table in descending order using for loop. void main(void) int n,i,s; printf("enter any no to get its table"); scanf("%d",&n); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 2 of 35
3 for(i=10;i>=0;i--) s=i*n; printf("%d*%d=%d\n",n,i,s); Q#2. Write a program that prints the square of all the numbers from 1 to 10. void main(void) int i; printf("number\tsquare\n"); for(i=1;i<=10;i++) printf("%d\t%d\n",i,i*i); Output Number. Square Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 3 of 35
4 Chap # 4 Q#2. Write a program that reads temperature and prints a message as given below. Temperature Message t>35 It is hot! t 20, t 35 Nice Day! T<20 It is cold! void main(void) int temp; printf("enter the temperature"); scanf("%d",&temp); if(temp>35) printf("it is hot!"); if(temp>=20 && temp<=35) printf("nice day"); if(temp<20) printf("it is cold!"); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 4 of 35
5 Q#3. Write a program that reads a phrase and prints the number of upper-case and lower-case in it. void main(void) char phrase[50]; int i,upper,lower; upper=0; lower=0; printf("enter any Phrase\n"); gets(phrase); for(i=0;i<strlen(phrase);i++) if(phrase[i]>=97 && phrase[i]<=122) lower=lower+1; if(phrase[i]>=65 && phrase[i]<=90) upper=upper+1; printf("the no of uppercase letter(s)= %d\n",upper); printf("the no of lowercase letter(s)= %d\n",lower); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 5 of 35
6 Q#4. Write a program that reads three numbers and prints the largest. void main(void) int a,b,c; printf("enter any three no.s and get the largest no."); scanf("%d %d %d",&a,&b,&c); if(a>b && a>c) printf("%d is the largest no ",a); else if(b>a && b>c) printf("%d is the largest no",b); else if(c>a && c>b) printf("%d is the largest no",c); else printf("all no. are equal"); Q#5. A class of 35 students took an Examination in which marks range from 0 to 100. Write a program which finds, a) The average marks. b) The number of students failed (Marks below 50). c) The number of students who scored 100 marks. void main() Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 6 of 35
7 int a[5],i,j=0,k=0,avg=0,sum=0; printf("enter the marks of 35 Students the range in 0-100\n if you exceed from this range then the program will be terminated"); for(i=0;i<5;i++) scanf("%d",&a[i]); if(a[i]<0 a[i]>100) printf("the range in dont exceed"); exit(1); //for average for(i=0;i<5;i++) sum+=a[i]; avg=sum/5; printf("the average is=%d\n",avg); //for the no of students failed (marks below 50) for(i=0;i<5;i++) if(a[i]<50) j++; if(a[i]==100) k++; printf("there are %d no of stdents are failed\n",j); printf("there are %d no of stdents scored 100 mark\n",k); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 7 of 35
8 Q#6. Write a program that prints all odd positive integers less than 100 skipping those that are exactly divisible by 7. void main(void) int i; i=1; while(i<=99) if(i%7!=0) printf("%d",i); i=i+2; Q#8. Write a program that reads the coefficients, a, b and c of the quadratic equation, ax 2 + bx + c = 0 And prints the real solution of x, using the following formula, Note that if, x = b± b 2 4ac 2a b2 4ac = 0 Then there is only one real solution. If it is greater than zero than there are two real solutions and if it is less than zero then print the message, NO REAL SOLUTION. Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 8 of 35
9 #include<math.h> void main(void) int a,b,c; double d=1.0,ans=1.0,e=2.0,sq=1.0,solution=1.0,solution2=1.0; printf("enter the coefficients of the quadratic equation\n"); scanf("%d%d%d",&a,&b,&c); sq=b*b; d=sq-(4*a*c); ans=pow(d,1/e); if(ans==0.0) printf("there is only one real solution\n"); solution=(-b+ans)/2*a; printf("the Solution is =%lf",solution); if(ans>0.0) printf("there are two solution\n"); solution=(-b+ans)/2*a; solution2=(-b-ans)/2*a; printf("the 1st Solution is =%lf\n",solution); printf("the 2nd solution is =%lf\n",solution2); if(ans<0.0) printf("no real Solution\n"); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 9 of 35
10 Chap # 5 Q#5. Write a program that reads n integers and print the smallest along with its subscript value in the list. void main() int a[5],i,temp; printf("enter any 5 no."); for(i=0;i<5;i++) scanf("%d",&a[i]); temp=a[0]; for(i=0;i<5;i++) if(a[i]<temp) temp=a[i]; printf("the smallest no. is %d",temp); Q#6. Write a program that reads two integer arrays, a and b having 5 elements each and prints the sum of the products as given below, Sum = a[0] * b[0] + a[1] * b[1] +.+ a[4] * b[4] void main() Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 10 of 35
11 int a[4],b[4],sum=0,i; printf("enter values in 1st array"); for(i=0;i<5;i++) scanf("%d",a[i]); printf("enter values in 2nd array"); for(i=0;i<5;i++) scanf("%d",b[i]); for(i=0;i<5;i++) sum=sum+a[i]*b[i]; printf("the sum is=%d",sum); Q#7. Write a program that reads n floating point numbers and prints the sum positive numbers. void main() float a[10],sum=0; int i; printf("enter any 10 no.s"); for(i=0;i<10;i++) Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 11 of 35
12 scanf("%f",&a[i]); for(i=0;i<10;i++) if(a[i]>0) sum=sum+a[i]; printf("the sum of Positive no.s is=%f",sum); Q#8. For a floating point array x whose size is n, find the geometric mean. GM = n x 1. x 2. x 3 x n #include<math.h> void main(void) float a[10]; double p=1.0,gm,e=10.0; int i; printf("enter no. to get its geometric mean"); for (i=0;i<10;i++) scanf("%f",&a[i]); for (i=0;i<10;i++) p=p*a[i]; gm=pow(p,1/e); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 12 of 35
13 printf("the GM is= %lf",gm); Q#9. Write codes that will print the following patterns. a) void main() int i,j; for(i=1;i<=5;i++) print("\n"); for(j=1;j<=i;j++) printf("%d\t",j); b) Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 13 of 35
14 void main() int i,j; for(i=5;i>=1;i--) printf("\n"); for(j=1;j<=i;j++) printf("%d\t",j); c) void main() int i,j; for(i=1;i<=5;i++) printf("\n"); for(j=i;j<=5;j++) printf("%d\t",j); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 14 of 35
15 d) * * * * * * * * * * * * * * * void main() int i,j; for(i=1;i<=5;i++) printf("\n"); for(j=1;j<=i;j++) printf("*\t"); Q#10. For two dimensional array x that has r rows and c columns, print the sum and average of each row. void main() int a[5][5],sum=0,i,j; float avg=1; printf("fill the Two dimensional array"); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 15 of 35
16 for(i=0;i<5;i++) for(j=0;j<5;j++) scanf("%d",&a[i][j]); for(i=0;i<5;i++) for(j=0;j<5;j++) sum=sum+a[i][j]; avg=sum/5; printf("the sum of %d row is=%d\n",i+1,sum); printf("the average is=%f\n",avg); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 16 of 35
17 Chap # 6 Q#2. Write a program that prints the larger of two numbers entered from the keyboard. Use a function to do the actual comparison of the two numbers. Pass the two numbers to the function as arguments and have the function return the answer with return (). int comparison(int,int); void main(void) int a,b,c; printf("enter any two no. to get the larger"); scanf("%d%d",&a,&b); c=comparison(a,b); printf("%d is the larger no.",c); int comparison(int x,int y) if(x>y) return x; else return y; Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 17 of 35
18 Q#3. Write a program using a function to calculate the area of a rectangle. int area(int,int); void main(void) int height,width,ans; printf("enter height of the rectangle\n"); scanf("%d",&height); printf("enter the width of the rectangle\n"); scanf("%d",&width); ans=area(height,width); printf("the area of the rectangle is %d",ans); int area(int a,int b) int c; c=a*b; return c; Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 18 of 35
19 Q#4. Write a program that produces the following table of temperature in Centigrade and Fahrenheit from 0 degrees to 50 degrees centigrade. Use a function for conversion. Centigrade Fahrenheit void conversion(); void main(void) int a,b,c; printf(" \n"); printf("centigrade\t"); printf("fahrenheit\n"); printf(" \n"); conversion(); void conversion() int c,f; for(c=0;c<=50;c=c+5) f=(9*c/5)+32; Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 19 of 35
20 printf("%d\t\t\t%d\n",c,f); Q#5. Write a program that reads a phrase and prints the number of lower-case letters in it using a function for counting. void couting(char[]); void main() char phrase[50]; printf("enter any phrase\n"); gets(phrase); couting(phrase); void couting(char p[]) int i,lower=0; for(i=0;i<strlen(p);i++) if(p[i]>=97 && p[i]<=122) lower++; printf("the no of lowercase letter(s)= %d",lower); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 20 of 35
21 Q#6. Write a program that reads n floating point number in an array and prints their product using a function. void product(float[]); void main(void) float a[5]; int i; printf("enter no. in the array to get it product\n"); for(i=0;i<5;i++) scanf("%f",&a[i]); product(a); void product(float a[]) float ans=1.0; int i; for(i=0;i<5;i++) ans=ans*a[i]; printf("the Product is %f",ans); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 21 of 35
22 Q#7. Write a program that reads numbers in two integer arrays, X and Y, of size m and n and prints them in ascending order using a function. void ascending(int[],int[]); void main(void) int i,a[5],b[5]; printf("enter the values in the 1st array\n"); for(i=0;i<5;i++) scanf("%d",&a[i]); printf("enter the values in the 2nd array\n"); for(i=0;i<5;i++) scanf("%d",&b[i]); ascending(a,b); void ascending(int a[],int b[]) int i,temp,j; temp=a[0]; for(j=4;j>=1;j--) for(i=0;i<j;i++) if(a[i]>a[i+1]) temp=a[i]; a[i]=a[i+1]; Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 22 of 35
23 a[i+1]=temp; for(j=4;j>=1;j--) for(i=0;i<j;i++) if(b[i]>b[i+1]) temp=b[i]; b[i]=b[i+1]; b[i+1]=temp; printf("the 1st array in ascending order\n"); for(j=0;j<5;j++) printf("%d\t",a[j]); printf("\nthe 2nd array in ascending order\n"); for(j=0;j<5;j++) printf("%d\t",b[j]); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 23 of 35
24 Chap # 7 Q#3. Write a program that will read a C source file and verify that the number of right and left braces in the file is equal. Use getc() function to read the file. #include<string.h> void main(void) FILE *fptr; int i,r,l; char ch,string[81]; r=0; l=0; fptr=fopen("student.txt","w"); while(strlen(gets(string))>0) fputs(string,fptr); fclose(fptr); fptr=fopen("student.txt","r"); if(fptr==null) puts("can not open file"); exit(); while((ch=fgetc(fptr))!=eof) if(ch=='(') l++; Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 24 of 35
25 if(ch==')') r++; if(l==r) printf("the Left and right brackets are equal "); else printf("the Left and Right brackets are not equal",l,r); fclose(fptr); Q#4. Write a program that will read names and marks of six subjects of five students and stores them in a file called result.txt. #include<string.h> void main(void) FILE *fptr; int i,j; char ch,name[40]; float marks; fptr=fopen("result.txt","w"); for(i=1;i<=5;i++) printf("enter the Name of student(%d)\n",i); scanf("%s",&name); fprintf(fptr,"%s",name); for(j=1;j<=6;j++) printf("the marks of %d subject",j); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 25 of 35
26 scanf("%f",&marks); fprintf(fptr,"%d",marks); fclose(fptr); Q#5. Write a program that will read names and marks of six subjects of five students from the result.txt file created in the previous question and prints each student s name along with his total and average marks. #include<string.h> void main(void) FILE *fptr; int i,j; char ch,name[40]; float avg=0,total=0,marks; fptr=fopen("result.txt","w"); for(i=1;i<=5;i++) printf("enter the Name of student(%d)\n",i); scanf("%s",&name); fprintf(fptr,"%s",name); for(j=1;j<=6;j++) printf("the marks of %d subject",j); scanf("%f",&marks); total=total+marks; fprintf(fptr,"%f",marks); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 26 of 35
27 avg=total/6; printf("the Total Marks are = %f\n",total); printf("the averge is = %f\n",avg); fprintf(fptr,"%f%f",total,avg); fclose(fptr); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 27 of 35
28 Important worksheets Format Specifiers There are many format specifiers defined in C. Take a look at the following list: %i or %d int %c char %f float %lf double %s string Note: %lf stands for long float. Let s take a look at an example of printf formatted output: main() int a,b; float c,d; a = 15; b = a / 2; printf("%d\n",b); printf("%3d\n",b); printf("%03d\n",b); c = 15.3; d = c / 3; printf("%3.2f\n",d); Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 28 of 35
29 Output of the source above: As you can see in the first printf statement we print a decimal. In the second printf statement we print the same decimal, but we use a width (%3d) to say that we want three digits (positions) reserved for the output. The result is that two space characters are placed before printing the character. In the third printf statement we say almost the same as the previous one. Print the output with a width of three digits, but fill the space with 0. In the fourth printf statement we want to print a float. In this printf statement we want to print three position before the decimal point (called width) and two positions behind the decimal point (called precision)... Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 29 of 35
30 Syntax for getch () in C : variable_name = getch() accepts only single character from keyboard. The character entered through getch() is not displayed in the screen (monitor). Syntax for getche() in C : variable_name = getche(); Like getch(), getche() also accepts only single character, but unlike getch(), getche() displays the entered character in the screen. Syntax for getchar() in C : variable_name = getchar(); getchar() accepts one character type data from the keyboard. Syntax for gets() in C : gets(variable_name); gets() accepts any line of string including spaces from the standard Input device (keyboard). gets() stops reading character from keyboard only when the enter key is pressed. The unformatted output statements in C are putch, putchar and puts. Syntax for putch in C : putch(variable_name); putch displays any alphanumeric characters to the standard output device. It displays only one character at a time. Syntax for putchar in C : putchar(variable_name); putchar displays one character at a time to the Monitor. Syntax for puts in C : puts(variable_name); puts displays a single / paragraph of text to the standard output device. Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 30 of 35
31 Sample program : gets_puts.c #include<conio.h> void main() char a[20]; gets(a); puts(a); Program Algorithm / Explanation 1. header file is included because, the C in-built statements gets and puts we used in this program comes under stdio.h header files. 2. #include<conio.h> is used because the C in-built function getch() comes under conio.h header files. 3. main () function is the place where C program execution begins. 4. Array a[] of type char size 20 is declared. 5. gets is used to receive user input to the array. gets stops receiving user input only when the Newline character (Enter Key) is interrupted. 6. puts is used to display them back in the monitor. Output : Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 31 of 35
32 Array Array is a collection of homogenous data stored under unique name. The values in an array are called as 'elements of an array.' These elements are accessed by numbers called as 'subscripts or index numbers.' Arrays may be of any variable type. Array is also called as 'subscripted variable.' Types of an Array: 1.One / Single Dimensional Array 2. Two Dimensional Array Single / One Dimensional Array: The array which is used to represent and store data in a linear form is called as 'single or one dimensional array.' Syntax: <Data-type> <array_name> [size]; Example: int a[3] = 2, 3, 5; char ch[20] = "TechnoExam" ; float stax[3] = , , ; Total Size (in Bytes): Total size = length of array * size of data type In above example, a is an array of type integer which has storage size of 3 elements. The total size would be 3 * 2 = 6 bytes. Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 32 of 35
33 Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 33 of 35
34 Features: Array size should be positive number only. String array always terminates with null character ('\0'). Array elements are countered from 0 to n-1. Useful for multiple reading of elements (numbers). Disadvantages: There is no easy method to initialize large number of array elements. It is difficult to initialize selected elements Two Dimensional Array The array which is used to represent and store data in a tabular form is called as 'two dimensional array.' Such type of array specially used to represent data in a matrix form. The following syntax is used to represent two dimensional array. Syntax: <data-type> <array_nm> [row_subscript][column-subscript]; Example: int a[3][3]; In above example, a is an array of type integer which has storage size of 3 * 3 matrix. The total size would be 3 * 3 * 2 = 18 bytes. It is also called as 'multidimensional array. Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 34 of 35
35 Limitations of two dimensional array: 1. We cannot delete any element from an array. 2. If we don t know that how many elements have to be stored in a memory in advance, then there will be memory wastage if large array size is specified. Aumir Shabbir Pakistan School Muscat (Class: XII) Page # 35 of 35
FEEG6002 - Applied Programming 5 - Tutorial Session
FEEG6002 - Applied Programming 5 - Tutorial Session Sam Sinayoko 2015-10-30 1 / 38 Outline Objectives Two common bugs General comments on style String formatting Questions? Summary 2 / 38 Objectives Revise
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
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,
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
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
arrays C Programming Language - Arrays
arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)
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
So far we have considered only numeric processing, i.e. processing of numeric data represented
Chapter 4 Processing Character Data So far we have considered only numeric processing, i.e. processing of numeric data represented as integer and oating point types. Humans also use computers to manipulate
5 Arrays and Pointers
5 Arrays and Pointers 5.1 One-dimensional arrays Arrays offer a convenient way to store and access blocks of data. Think of arrays as a sequential list that offers indexed access. For example, a list of
CP Lab 2: Writing programs for simple arithmetic problems
Computer Programming (CP) Lab 2, 2015/16 1 CP Lab 2: Writing programs for simple arithmetic problems Instructions The purpose of this Lab is to guide you through a series of simple programming problems,
Lecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c
Lecture 3 Data structures arrays structs C strings: array of chars Arrays as parameters to functions Multiple subscripted arrays Structs as parameters to functions Default arguments Inline functions Redirection
Chapter One Introduction to Programming
Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of
NSM100 Introduction to Algebra Chapter 5 Notes Factoring
Section 5.1 Greatest Common Factor (GCF) and Factoring by Grouping Greatest Common Factor for a polynomial is the largest monomial that divides (is a factor of) each term of the polynomial. GCF is the
Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language
Simple C++ Programs Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input and Output Basic Functions from
Sect 6.7 - Solving Equations Using the Zero Product Rule
Sect 6.7 - Solving Equations Using the Zero Product Rule 116 Concept #1: Definition of a Quadratic Equation A quadratic equation is an equation that can be written in the form ax 2 + bx + c = 0 (referred
Answers to Review Questions Chapter 7
Answers to Review Questions Chapter 7 1. The size declarator is used in a definition of an array to indicate the number of elements the array will have. A subscript is used to access a specific element
SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison
SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89 by Joseph Collison Copyright 2000 by Joseph Collison All rights reserved Reproduction or translation of any part of this work beyond that permitted by Sections
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
4. How many integers between 2004 and 4002 are perfect squares?
5 is 0% of what number? What is the value of + 3 4 + 99 00? (alternating signs) 3 A frog is at the bottom of a well 0 feet deep It climbs up 3 feet every day, but slides back feet each night If it started
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
Ad Hoc Advanced Table of Contents
Ad Hoc Advanced Table of Contents Functions... 1 Adding a Function to the Adhoc Query:... 1 Constant... 2 Coalesce... 4 Concatenate... 6 Add/Subtract... 7 Logical Expressions... 8 Creating a Logical Expression:...
(Eng. Hayam Reda Seireg) Sheet Java
(Eng. Hayam Reda Seireg) Sheet Java 1. Write a program to compute the area and circumference of a rectangle 3 inche wide by 5 inches long. What changes must be made to the program so it works for a rectangle
December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS
December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B KITCHENS The equation 1 Lines in two-dimensional space (1) 2x y = 3 describes a line in two-dimensional space The coefficients of x and y in the equation
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
(hours worked,rateofpay, and regular and over time pay) for a list of employees. We have
Chapter 9 Two Dimensional Arrays In Chapter 7 we have seen that C provides a compound data structure for storing a list of related data. For some applications, however, such a structure may not be sucient
YOU CAN COUNT ON NUMBER LINES
Key Idea 2 Number and Numeration: Students use number sense and numeration to develop an understanding of multiple uses of numbers in the real world, the use of numbers to communicate mathematically, and
ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters
The char Type ASCII Encoding The C char type stores small integers. It is usually 8 bits. char variables guaranteed to be able to hold integers 0.. +127. char variables mostly used to store characters
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
Senem Kumova Metin & Ilker Korkmaz 1
Senem Kumova Metin & Ilker Korkmaz 1 A loop is a block of code that can be performed repeatedly. A loop is controlled by a condition that is checked each time through the loop. C supports two categories
C PROGRAMMING FOR MATHEMATICAL COMPUTING
UNIVERSITY OF CALICUT SCHOOL OF DISTANCE EDUCATION BSc MATHEMATICS (2011 Admission Onwards) VI Semester Elective Course C PROGRAMMING FOR MATHEMATICAL COMPUTING QUESTION BANK Multiple Choice Questions
A Concrete Introduction. to the Abstract Concepts. of Integers and Algebra using Algebra Tiles
A Concrete Introduction to the Abstract Concepts of Integers and Algebra using Algebra Tiles Table of Contents Introduction... 1 page Integers 1: Introduction to Integers... 3 2: Working with Algebra Tiles...
B.Sc.(Computer Science) and. B.Sc.(IT) Effective From July 2011
NEW Detailed Syllabus of B.Sc.(Computer Science) and B.Sc.(IT) Effective From July 2011 SEMESTER SYSTEM Scheme & Syllabus for B.Sc. (CS) Pass and Hons. Course Effective from July 2011 and onwards CLASS
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
J a v a Quiz (Unit 3, Test 0 Practice)
Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points
Module 816. File Management in C. M. Campbell 1993 Deakin University
M. Campbell 1993 Deakin University Aim Learning objectives Content After working through this module you should be able to create C programs that create an use both text and binary files. After working
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
Notes on Determinant
ENGG2012B Advanced Engineering Mathematics Notes on Determinant Lecturer: Kenneth Shum Lecture 9-18/02/2013 The determinant of a system of linear equations determines whether the solution is unique, without
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
Moving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
FACTORING QUADRATICS 8.1.1 and 8.1.2
FACTORING QUADRATICS 8.1.1 and 8.1.2 Chapter 8 introduces students to quadratic equations. These equations can be written in the form of y = ax 2 + bx + c and, when graphed, produce a curve called a parabola.
Factoring and Applications
Factoring and Applications What is a factor? The Greatest Common Factor (GCF) To factor a number means to write it as a product (multiplication). Therefore, in the problem 48 3, 4 and 8 are called the
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
Microsoft Excel Tips & Tricks
Microsoft Excel Tips & Tricks Collaborative Programs Research & Evaluation TABLE OF CONTENTS Introduction page 2 Useful Functions page 2 Getting Started with Formulas page 2 Nested Formulas page 3 Copying
Data Analysis Tools. Tools for Summarizing Data
Data Analysis Tools This section of the notes is meant to introduce you to many of the tools that are provided by Excel under the Tools/Data Analysis menu item. If your computer does not have that tool
COMPUTER SCIENCE 1999 (Delhi Board)
COMPUTER SCIENCE 1999 (Delhi Board) Time allowed: 3 hours Max. Marks: 70 Instructions: (i) All the questions are compulsory. (ii) Programming Language: C++ QUESTION l. (a) Why main function is special?
Python Lists and Loops
WEEK THREE Python Lists and Loops You ve made it to Week 3, well done! Most programs need to keep track of a list (or collection) of things (e.g. names) at one time or another, and this week we ll show
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
Solving Quadratic Equations by Factoring
4.7 Solving Quadratic Equations by Factoring 4.7 OBJECTIVE 1. Solve quadratic equations by factoring The factoring techniques you have learned provide us with tools for solving equations that can be written
Part I. Multiple Choice Questions (2 points each):
Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******
A Brief Introduction to MySQL
A Brief Introduction to MySQL by Derek Schuurman Introduction to Databases A database is a structured collection of logically related data. One common type of database is the relational database, a term
Solution of Linear Systems
Chapter 3 Solution of Linear Systems In this chapter we study algorithms for possibly the most commonly occurring problem in scientific computing, the solution of linear systems of equations. We start
7th Marathon of Parallel Programming WSCAD-SSC/SBAC-PAD-2012
7th Marathon of Parallel Programming WSCAD-SSC/SBAC-PAD-2012 October 17 th, 2012. Rules For all problems, read carefully the input and output session. For all problems, a sequential implementation is given,
Factoring Quadratic Expressions
Factoring the trinomial ax 2 + bx + c when a = 1 A trinomial in the form x 2 + bx + c can be factored to equal (x + m)(x + n) when the product of m x n equals c and the sum of m + n equals b. (Note: the
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.
Arrays. number: Motivation. Prof. Stewart Weiss. Software Design Lecture Notes Arrays
Motivation Suppose that we want a program that can read in a list of numbers and sort that list, or nd the largest value in that list. To be concrete about it, suppose we have 15 numbers to read in from
Conditionals (with solutions)
Conditionals (with solutions) For exercises 1 to 27, indicate the output that will be produced. Assume the following declarations: final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87;
Chapter 13 Storage classes
Chapter 13 Storage classes 1. Storage classes 2. Storage Class auto 3. Storage Class extern 4. Storage Class static 5. Storage Class register 6. Global and Local Variables 7. Nested Blocks with the Same
1.3 Algebraic Expressions
1.3 Algebraic Expressions A polynomial is an expression of the form: a n x n + a n 1 x n 1 +... + a 2 x 2 + a 1 x + a 0 The numbers a 1, a 2,..., a n are called coefficients. Each of the separate parts,
PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include 2 + 5.
PUTNAM TRAINING POLYNOMIALS (Last updated: November 17, 2015) Remark. This is a list of exercises on polynomials. Miguel A. Lerma Exercises 1. Find a polynomial with integral coefficients whose zeros include
Florida Math 0028. Correlation of the ALEKS course Florida Math 0028 to the Florida Mathematics Competencies - Upper
Florida Math 0028 Correlation of the ALEKS course Florida Math 0028 to the Florida Mathematics Competencies - Upper Exponents & Polynomials MDECU1: Applies the order of operations to evaluate algebraic
Name: Section Registered In:
Name: Section Registered In: Math 125 Exam 3 Version 1 April 24, 2006 60 total points possible 1. (5pts) Use Cramer s Rule to solve 3x + 4y = 30 x 2y = 8. Be sure to show enough detail that shows you are
Sample Questions Csci 1112 A. Bellaachia
Sample Questions Csci 1112 A. Bellaachia Important Series : o S( N) 1 2 N N i N(1 N) / 2 i 1 o Sum of squares: N 2 N( N 1)(2N 1) N i for large N i 1 6 o Sum of exponents: N k 1 k N i for large N and k
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
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.
( ) FACTORING. x In this polynomial the only variable in common to all is x.
FACTORING Factoring is similar to breaking up a number into its multiples. For example, 10=5*. The multiples are 5 and. In a polynomial it is the same way, however, the procedure is somewhat more complicated
The C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
= 2 + 1 2 2 = 3 4, Now assume that P (k) is true for some fixed k 2. This means that
Instructions. Answer each of the questions on your own paper, and be sure to show your work so that partial credit can be adequately assessed. Credit will not be given for answers (even correct ones) without
Lab Manual. Databases. Microsoft Access. Peeking into Computer Science Access Lab manual
Lab Manual Databases Microsoft Access 1 Table of Contents Lab 1: Introduction to Microsoft Access... 3 Getting started... 3 Tables... 3 Primary Keys... 6 Field Properties... 7 Validation Rules... 11 Input
MAT188H1S Lec0101 Burbulla
Winter 206 Linear Transformations A linear transformation T : R m R n is a function that takes vectors in R m to vectors in R n such that and T (u + v) T (u) + T (v) T (k v) k T (v), for all vectors u
APPLICATIONS AND MODELING WITH QUADRATIC EQUATIONS
APPLICATIONS AND MODELING WITH QUADRATIC EQUATIONS Now that we are starting to feel comfortable with the factoring process, the question becomes what do we use factoring to do? There are a variety of classic
Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html
CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install
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
Data Structures using OOP C++ Lecture 1
References: 1. E Balagurusamy, Object Oriented Programming with C++, 4 th edition, McGraw-Hill 2008. 2. Robert Lafore, Object-Oriented Programming in C++, 4 th edition, 2002, SAMS publishing. 3. Robert
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)
An Incomplete C++ Primer. University of Wyoming MA 5310
An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages
MATLAB Basics MATLAB numbers and numeric formats
MATLAB Basics MATLAB numbers and numeric formats All numerical variables are stored in MATLAB in double precision floating-point form. (In fact it is possible to force some variables to be of other types
Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.
Algebra 2 - Chapter Prerequisites Vocabulary Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any. P1 p. 1 1. counting(natural) numbers - {1,2,3,4,...}
Analysis of Binary Search algorithm and Selection Sort algorithm
Analysis of Binary Search algorithm and Selection Sort algorithm In this section we shall take up two representative problems in computer science, work out the algorithms based on the best strategy to
Engineering Problem Solving and Excel. EGN 1006 Introduction to Engineering
Engineering Problem Solving and Excel EGN 1006 Introduction to Engineering Mathematical Solution Procedures Commonly Used in Engineering Analysis Data Analysis Techniques (Statistics) Curve Fitting techniques
MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m
MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS 1. SYSTEMS OF EQUATIONS AND MATRICES 1.1. Representation of a linear system. The general system of m equations in n unknowns can be written a 11 x 1 + a 12 x 2 +
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 :
Solving Quadratic Equations
9.3 Solving Quadratic Equations by Using the Quadratic Formula 9.3 OBJECTIVES 1. Solve a quadratic equation by using the quadratic formula 2. Determine the nature of the solutions of a quadratic equation
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
SMT 2014 Algebra Test Solutions February 15, 2014
1. Alice and Bob are painting a house. If Alice and Bob do not take any breaks, they will finish painting the house in 20 hours. If, however, Bob stops painting once the house is half-finished, then the
a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2.
Chapter 1 LINEAR EQUATIONS 1.1 Introduction to linear equations A linear equation in n unknowns x 1, x,, x n is an equation of the form a 1 x 1 + a x + + a n x n = b, where a 1, a,..., a n, b are given
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
Vocabulary Words and Definitions for Algebra
Name: Period: Vocabulary Words and s for Algebra Absolute Value Additive Inverse Algebraic Expression Ascending Order Associative Property Axis of Symmetry Base Binomial Coefficient Combine Like Terms
Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example
Announcements Memory management Assignment 2 posted, due Friday Do two of the three problems Assignment 1 graded see grades on CMS Lecture 7 CS 113 Spring 2008 2 Safe user input If you use scanf(), include
Chapter 3. Input and output. 3.1 The System class
Chapter 3 Input and output The programs we ve looked at so far just display messages, which doesn t involve a lot of real computation. This chapter will show you how to read input from the keyboard, use
The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).
CHAPTER 5 The Tree Data Model There are many situations in which information has a hierarchical or nested structure like that found in family trees or organization charts. The abstraction that models hierarchical
The programming language C. sws1 1
The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan
3.GETTING STARTED WITH ORACLE8i
Oracle For Beginners Page : 1 3.GETTING STARTED WITH ORACLE8i Creating a table Datatypes Displaying table definition using DESCRIBE Inserting rows into a table Selecting rows from a table Editing SQL buffer
15.062 Data Mining: Algorithms and Applications Matrix Math Review
.6 Data Mining: Algorithms and Applications Matrix Math Review The purpose of this document is to give a brief review of selected linear algebra concepts that will be useful for the course and to develop
FX 115 MS Training guide. FX 115 MS Calculator. Applicable activities. Quick Reference Guide (inside the calculator cover)
Tools FX 115 MS Calculator Handouts Other materials Applicable activities Quick Reference Guide (inside the calculator cover) Key Points/ Overview Advanced scientific calculator Two line display VPAM to
EXCEL Tutorial: How to use EXCEL for Graphs and Calculations.
EXCEL Tutorial: How to use EXCEL for Graphs and Calculations. Excel is powerful tool and can make your life easier if you are proficient in using it. You will need to use Excel to complete most of your
sqlite driver manual
sqlite driver manual A libdbi driver using the SQLite embedded database engine Markus Hoenicka [email protected] sqlite driver manual: A libdbi driver using the SQLite embedded database engine
Programming Languages CIS 443
Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception
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
MAT 2170: Laboratory 3
MAT 2170: Laboratory 3 Key Concepts The purpose of this lab is to familiarize you with arithmetic expressions in Java. 1. Primitive Data Types int and double 2. Operations involving primitive data types,
What is the consequences of no break statement in a case.
REVIEW DID YOU THINK ABOUT THE SUBTLE ISSUES HERE The Example using the switch statement. PLAY COMPUTER in class show in a table the values of the variables for the given input!!!! char ch; int ecount=0,
