C programming: exercise sheet L2-STUE ( )

Save this PDF as:

Size: px
Start display at page:

Transcription

1 C programming: exercise sheet L2-STUE ( ) Algorithms and Flowcharts Exercise 1: comparison Write the flowchart and associated algorithm that compare two numbers a and b. Exercise 2: 2 nd order polynomials Work out the algorithm that output the solutions of a 2 nd order polynomial ax 2 +bx+c=0, given the parameters a, b and c. Only real solutions will be treated. The cases with 1 or 2 solutions will be separated. Exercise 3: XOR Write the flowchart of the XOR logical gate defined by X Y X XOR Y Exercise 4: Minimum of three numbers Find the flowchart and algorithm of a program that finds the minimum of three values a, b and c. Exercise 5: Guess a number Write the flowchart and algorithm of a program where the user is asked to find an integer number between 1 and 50. Exercise 6: sum, average and root-mean-square Define the flowchart of a program where the user supplies integer values between 1 and 9 and the program returns the sum, average and RMS of the values. The program will exit when 0 is entered. Values outside of the bounds will be discarded. Write the corresponding algorithm. Exercise 7: father and son (or mother and daughter) Define an algorithm that returns the number of years until a father will have an age double of its son s age.

2 Variables and types Exercise 8: first step. Write the C code that prints in the shell the sentence: hello word!. Use the printf function of the <stdio.h> library to print on the screen. In the shell, you will use the gcc compiler to produce an executable code (the instruction man gcc will print the manual of the gcc compiler). Exercise 9: reading from the keyboard. Write a C code that asks the user to supply to integer numbers and then prints the two numbers and their sum on the shell. You will use the scanf function to read the two numbers. Exercise 10: divisions Starting from the following declarations int a=2,b=3,c; float x=5.0,y; Predict the outcome of the operations y=a*b; c=a*b; y=a/b; c=a/b; y=a/b*x; c=a/b*x; y=a*x/b; c=a*x/b; Write the corresponding C code to check your predictions. You will use the printf command (<stdio.h>) to output the results on the screen. Note that you will have to use %i to print an integer and %f to print a float. Exercise 11: casts In exercise 8, use cast operations to output the decimal result. In which case does it not work? Exercise 12: time conversion Given a time in seconds (integer), print to the screen the corresponding time in hours, minutes and seconds. The output will be formatted like: XXXX seconds is equivalent to XX hours, XX minutes and XX seconds.

3 Exercise 13: constants and pi Write a C code that computes the surface of a disk given its radius (use scanf). The number pi will be declared as a constant in the file. In a second step, you will call the <math.h> library, which defines pi. Look where the library is located on the disk then find how pi is defined (use the UNIX command locate). Modify your code to use this library instead of the constant defined in the previous version. Exercise 14: switch Write a C code that switches the values of two variables A and B and prints the result on the screen. How many variables do you need? Exercise 15: addition and memory Write a C code that sums 4 integer numbers (entered using scanf) using: 1) 5 variables (numbers are kept in variables) 2) 2 variables (no memory of the entries kept) Exercise 16: distance Write a C code that calculates the distance between two points whose coordinates in the [X,Y] plane are read from the keyboard as integer. Handling conditions Exercise 17: XOR Write the C code that corresponds to exercise 3 and test it. Exercise 18: 2 nd order polynomial Write the C code that corresponds to exercise 2 and test it. Exercise 19: maximum of three numbers Write a program that reads three integers (A, B and C) and prints the largest of the values using: 1) the if-else structure and a temporary variable 2) if-else structures without a temporary variable 3) conditional operations Exercise 20: sign of a multiplication Write a C code that returns the sign of a multiplication of A and B without doing the multiplication.

4 Exercise 21: parity Write the C code that returns the parity of a number. Define the proper mathematical test and the associated C condition. The number will be read from the keyboard using the scanf function of the <stdio.h> library. Exercise 22: sign of Using the if-else condition then the switch condition and finally the ternary operator, write a C code that prints the sign of an integer. Sign returns 1 for a positive number, -1 for a negative number and 0 if the value is 0. Exercise 23: day of the week Write a program that outputs the day of the week given a date expressed as j (day) m (month) a (year). You will use the following formula: and with n s being the two first digits of a 1 and a s the two last digits of a 1 The day of the week will then be given by the modulo of f and 7 (0 is Sunday, 1 Monday etc). Using loops Exercise 24: prime numbers Write a program that tests if a positive integer is a prime number using a straightforward approach. You will assume that your number is smaller than Exercise 25: factorial Write a C code that computes the factorial of an integer n. When does the code fail (upper limit on n for the result to be correct) and why? Exercise 26: x n Write the C code that computes x n using the three loop functions (for, while and do-while). We will consider n to be an integer.

5 Exercise 27: pyramid Write a C code that permits the user to specify a number of lines and then prints on the shell a pyramid consisting of stars. The pyramid must be centered. Hints: all characters are printed separately and both the number of stars per line and the number of spaces per line must be calculated. The output will look like: Exercise 28: min, max, average Using a loop, ask the user to enter positive integer numbers. The program will output the number of values entered, the minimum value, the maximum value and the average of all numbers. The code will exit once a negative integer is entered. Exercise 29: counting entries. Write a program, which counts the number of time an integer between 0 and 9 has been entered by the user. The program will ask the user to enter a number between 0 and 9, exit when a negative number is entered (values outside of the range will be discarded). Upon exit, it will print the number of 0, 1 entered. Exercise 30: zero of a function Write a C code that finds the zero of a function y=a.x+b (eg x such as y=0) without solving the equation. The zero will be found within a precision limit eps=10-3. You will start from a fixed point at x=0 and move x in the proper direction until abs(y)<eps. Tables and arrays Exercise 31: are two vectors orthogonal? Consider 2 three-dimensional vectors X and Y whose components are specified by the user and stored in 1D arrays. Write the C code that calculates if the two vectors are orthogonal.

6 Exercise 32: reversing an array Consider an array X (type float) of length n. Write the C code that prints the array Y, which is X in reverse order. Exercise 33: minimum and position Consider an array X of length n randomly initialized. Write a program that returns the position and value of the minimum. Exercise 34: polynomial Given a polynomial of degree n defined as follow 1) find the algorithm that allows you to calculate f(x) without the use of the power function 2) write the associated C code assuming n<50. The user will be asked to supply the degree of the polynomial as well as the coefficients a i. The coefficients will be stored in an array. Exercise 35: sorting an array (simple sort) Consider an array of integers of size n, whose values are set randomly using the rand() function. Write a C code that sorts the elements from the smallest to the largest value. One will proceed as follow: 1) search for the minimum of the elements 0 to n-1. Swap the minimum and first element. 2) Search for the minimum of the elements 1 to n-1. Swap the minimum and second element. 3) 4) repeat until the array is sorted. Exercise 36: matrix product Write the C code that computes the product of two 3x3 matrices. The code must print the result on the screen. Exercise 37: concatenation of two tables Consider X and Y, two sorted arrays of integers. Write a C code that concatenates the two tables into one table Z (sorted) which contains the elements of X and Y. Functions and recursive programming Exercise 38: simple functions Write two C functions that compute f(x)=2.3*x and g(x,y)=x*y.

7 Exercise 39: factorial function Write a C function facto that computes the factorial of a number n (integer) as in exercise 25. The factorial function is a typical recursive problem. Rewrite the equation defining the factorial function in a recursive form. Write the recursive version of the code and call the function facto_rec. Exercise 40: x n Rewrite x n in its recursive form and write the associate C function that you will call pow_rec. Exercise 41: exponential function The Taylor expansion of the exponential function is given by. Using the previous exercises, write a C functions that calculates the exponential for integer values of x. Compare its results to the results of the C exponential function defined in <math.h>. Exercise 42: polynomial and derivatives Assuming that the coefficients of a polynomial are stored in an array a (we will assume its dimension n is at max 50), write a C code that computes its derivative at a point x specified by the user. Exercise 43: simple integration Same as exercise 42 but now the function returns the integral of the polynomial between two points. You will use two different methods: 1- analytical method: using the coefficients you will compute the integral from a to b of the polynomial 2- numerical method: use the trapeze method fixing dx. Discuss the impact of dx on the accuracy of the result. Exercise 44: is_prime Write a function that returns 1 if a integer number is prime, 0 otherwise.

8 Pointers and structures Exercise 45: pointer algebra Using the following declarations: int A[]={2,6,5,1,3}; int *p; p=a; what is the result of the instructions: 1) *p 6) p 11) p+(*(p+4)-3) 2) *p+2 7) A 3) *(p+2) 8) &A[0] 4) &p 9) &A[0]+3 5) &p+1 10) A+3 Exercise 46: complex number and structure Create a structure to store a complex number and write three functions (for addition, multiplication and norm) that handle this new structure. Exercise 47: structures (cont.) Write a program that will stores the personal information of a student (such as name, date of birth, address) in a structure that you will define and then prints the record on the screen. A table of characters can be defined using pointers such as char *myline. Exercise 48: pointers and functions Write a function of type void that takes as input a table of integers and returns the minimum maximum and sum in three variables. We will assume that the table contains 50 numbers. Exercise 49: conundrum What does this function do?

9 Exercise 50: conundrum 2 What are the outputs of this code? Explain. Exercise 51: chained lists Using pointers and structures, create a chained list in a C program. The elements of the list will describe the record of an employee. The global structure will follow this scheme: The C program will provide two functions to add a new record and remove the last record. Strings Exercise 52: storing and printing Write a small C program that prints on the screen a text supplied by the user. The string will not be more than 80 characters in size. Exercise 53: handling strings Write a small C program that prints each word of a user-supplied text on a new line. Exercise 54: lower to upper case Using the integer representation of a character, write a function that replaces all the lower case characters in a string by upper case characters. Exercise 55: strcpy Write three version of a function that takes one string as input and copies it on a second string. You will first use the tabular structure of a string then pointers and finally pointer arithmetic.

10 Exercise 56: palindrome Write a program that tests if a user-supplied sentence is a palindrome. The program should not be case sensitive. Exercise 57: characters and strings Given a string as input, write a function that counts the numbers, the lower case, upper case and special characters. Exercise 58: extracting characters From a user-supplied string, write a program that extracts the sentences one by one. Input/Output and files For these exercises we assume that the files contain ASCII characters (not binary files). Exercise 59: reading from a file Write a program that reads the content of a file and prints it on the screen. Exercise 60: writing in a file Write a program that prints x and x 2 in a file for x=1 to 10 by steps of 0.1. Exercise 61: reading and writing Using the structure student (ex 47) that contains the personal information of a student, write a program that asks the user to enter his/her information and stores it in an existing file named student.txt. If the file does not exist, it will be created. After the user has supplied his information, the program will print on the screen all the student information available in the file. Putting things together Exercise 62: direct Monte-Carlo and the value of pi. Using random numbers, design a simple method to estimate the value of pi. Write the corresponding code and print in a file the convergence of the solution. Hint: compare the surface of a square and a circle. Exercise 63: tic-tac-toe Write the C code that permits to play the tic-tac-toe game. The winner will be saved in a file.

11 Exercise 64: towers of Hanoi The towers of Hanoi is a mathematical game where a number of disks of decreasing size from bottom to top are set on the left of a set of three rods. The goal is to move the stack of disks to another rod, obeying the following rules: -only one disk may be moved at a time -each move consists of taking the upper disk from one rod and sliding it onto another rod -no disk may be placed on top of a smaller disk. Write a C program that solves this problem and prints to the screen the different moves. Hint: the solution is purely recursive.

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,

2013 Five years Integrated M.Sc.(IT) Semester 1 060010101 - Fundamentals of Programming

03 Five years Integrated M.Sc.(IT) Semester 00000 - Fundamentals Programming File should contain. Problem Statement. Algorithm 3. Flowchart. Program in C language(code) 5. Output and sample calculation

BHARATHIAR UNIVERSITY: COIMBATORE CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++ LANGUAGE

Certificate in Advanced Programming - C++ Language Page 1 of 7 BHARATHIAR UNIVERSITY: COIMBATORE 641046 CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++

MLR Institute of Technology

MLR Institute of Technology DUNDIGAL 500 043, HYDERABAD COMPUTER SCIENCE AND ENGINEERING Computer Programming Lab List of Experiments S.No. Program Category List of Programs 1 Operators a) Write a C program

Fundamentals of Computer & Programming in C Short-answer type questions

Fundamentals of Computer & Programming in C Short-answer type questions Section- A i. What is a computer system? Draw the block diagram of computer. ii. Differentiate between Real Time Operating System

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR ODD/EVEN ACADEMICSEMESTER (2014-15) ASSIGNMENT / QUESTION BANK (2110003) [F.Y.B.E.

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR ODD/EVEN ACADEMICSEMESTER (2014-15) ASSIGNMENT / QUESTION BANK Subject: Computer Programming and Utilization (2110003) [F.Y.B.E.: ALL BRANCHES] Unit 1

FBCA-02 April-2007 Programming in C Language BCA-102 (New Course)

Seat No. : FBCA-02 April-2007 Programming in C Language BCA-102 (New Course) Time : 3 Hours] [Max. Marks : 70 Instructions : (1) Figures to the right indicate full marks of the question. (2) Make and state

6.096 Lab 1. Due: 7 January 12:30:00. September 20, 2011

6.096 Lab 1 Due: 7 January 1:30:00 September 0, 011 1 Additional Material 1.1 Constants A constant is an expressions with a fixed value. Kinds of constants: Literals: used to express particular values

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANKULATHUR 603 203 DEPARTMENT OF COMPUTER APPLICATIONS QUESTION BANK IN REVISED BLOOM S TAXONOMY

ACADEMIC YEAR: 0 7 VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANKULATHUR 0 0 SEMESTER: ODD BRANCH: MCA YEAR: I SEMESTER: I SUBJECT CODE AND NAME: MC70 Problem Solving and Programming NAME OF THE FACULTY

Introduction to C Programming S Y STEMS

Introduction to C Programming CS 40: INTRODUCTION TO U NIX A ND L I NUX O P E R AT ING S Y STEMS Objectives Introduce C programming, including what it is and what it contains, which includes: Command line

AFF 826. Sub. Code 4BSO1C1. Sp2. B.Sc. DEGREE EXAMINATION, NOVEMBER First Semester. Software FUNDAMENTALS OF COMPUTERS AND C PROGRAMMING

Sp2 AFF 826 Sub. Code 4BSO1C1 B.Sc. DEGREE EXAMINATION, NOVEMBER 2015 First Semester Software FUNDAMENTALS OF COMPUTERS AND C PROGRAMMING (CBCS 2014 onwards) Time : 3 Hours Maximum : 75 Marks Part A (10

Marathwada Institute of Technology Master of Computer Application Title of the subject: Object Oriented Programming using C++ Course Code: MCA 101 Faculty: Shubhashree Savant Class: FY MCA Part - I (Question

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

GTU Questions. Computer Programming & Utilization. Chief Course Coordinator Prof. Mitul K.Patel. (Head of Department & Assistant Professor)

GTU Questions Computer Programming & Utilization Chief Course Coordinator Prof. Mitul K.Patel (Head of Department & Assistant Professor) Course Coordinator Prof. Vrutti D. Shah (Assistant Professor) Lab

Branching. We ll continue to look at the basics of writing C++ programs including. Overview

Branching Overview We ll continue to look at the basics of writing C++ programs including Boolean Expressions (need to know this before we can using branching and looping!) Branching J.S. Bradbury CSCI

PE1 Worksheet. 3) What are the three control structures for writing an algorithm in pseudocode?

PE1 Worksheet Problem solving 1) What are the four stages of problem solving by programming? What shall be done in each stage? Stage 1: Stage 2: Stage 3: Stage 4: 2) What is the top-down design strategy

Introduction to Programming Block Tutorial C/C++

Michael Bader Master s Program Computational Science and Engineering C/C++ Tutorial Overview From Maple to C Variables, Operators, Statements Functions: declaration, definition, parameters Arrays and Pointers

CSI 333 Lecture 2 Introduction to C: Part I 2 1 / 16

CSI 333 Lecture 2 Introduction to C: Part I 2 1 / 16 Basics of C Remark: Skim Chapters 1 through 6 of Deitel & Deitel. You will notice the following: C is (more or less) a subset of Java. (So, you are

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)

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

10CS35: Data Structures Using C

CS35: Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C OBJECTIVE: Learn : Usage of structures, unions - a conventional tool for handling a

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

Final Exam Review. CS 1428 Fall Jill Seaman. Final Exam

Final Exam Review CS 1428 Fall 2011 Jill Seaman 1 Final Exam Friday, December 9, 11:00am to 1:30pm Derr 241 (here) Closed book, closed notes, clean desk Comprehensive (covers entire course) 25% of your

Model Paper Computer Science Objective. Paper Code Time Allowed: 20 minutes

Note: This is Model Paper for guidance of students & teachers. Q. Model Paper Computer Science Objective Intermediate Part II ( th Class) Examination Session -4 and onward Total marks: 7 Paper Code Time

Dept. of CSE, IIT KGP

Basic Programming Concepts CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Some Terminologies Algorithm / Flowchart

MIT Aurangabad FE Computer Engineering Unit 1: Introduction to C 1. The symbol # is called a. Header file c. include b. Preprocessor d. semicolon 2. The size of integer number is limited to a. -32768 to

INDEX. C programming Page 1 of 10. 5) Function. 1) Introduction to C Programming

INDEX 1) Introduction to C Programming a. What is C? b. Getting started with C 2) Data Types, Variables, Constants a. Constants, Variables and Keywords b. Types of Variables c. C Keyword d. Types of C

Introduction to C ++ : Questions

Introduction to C ++ : Questions Thomas Branch 28th November 204. A Tutorial Introduction. Getting Started Aim: Make sure the program compiles and runs, learn to get the program to output text. [Debug]

Polynomials Classwork

Polynomials Classwork What Is a Polynomial Function? Numerical, Analytical and Graphical Approaches Anatomy of an n th -degree polynomial function Def.: A polynomial function of degree n in the vaiable

IMPERATIVE PROGRAMMING C LANGUAGE

J.NAWROCKI, M. ANTCZAK, H. ĆWIEK, W. FROHMBERG, A. HOFFA, M. KIERZYNKA, S. WĄSIK IMPERATIVE PROGRAMMING C LANGUAGE EX. 1. Write in C language programs described below, compile them and tentatively debug:

C AND C++ PROGRAMMING

C AND C++ PROGRAMMING Bharathidasan University A Courseware prepared by University Informatics Centre Part I - Programming in C Getting Started This courseware is intended to be an introduction to C programming

Basic Common Unix commands: Change to directory d

Basic Common Unix commands: cd d Change to directory d mkdir d rmdir d mv f1 [f2...] d mv d1 d2 ls [d] [f...] ls -1 [f...] vi [f] emacs [f] more f cp f1 f2 mv f1 f2 rm f gcc [-o f1] f2 gnuplot Create new

Pseudocode. Pseudocode. Guide for Pseudocode. Computers in Engineering Pseudocode and C Language Review. Example Pseudocode.

Computers in Engineering Pseudocode and C Language Review Pseudocode Pseudocode is an artificial and informal language that helps you develop algorithms Pseudocode is similar to everyday English; it is

3) Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

Freshers Club Important 100 C Interview Questions & Answers 1) How do you construct an increment statement or decrement statement in C? There are actually two ways you can do this. One is to use the increment

PES Institute of Technology-BSC QUESTION BANK

PES Institute of Technology-BSC Faculty: Mrs. R.Bharathi CS35: Data Structures Using C QUESTION BANK UNIT I -BASIC CONCEPTS 1. What is an ADT? Briefly explain the categories that classify the functions

Overview of a C Program

Overview of a C Program Programming with C CSCI 112, Spring 2015 Patrick Donnelly Montana State University Programming with C (CSCI 112) Spring 2015 2 / 42 C Language Components Preprocessor Directives

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

Looping Exercises Deciding Which Loop to Use

Looping Exercises Deciding Which Loop to Use At this time you have learned four looping constructs (also called repetition statements). Each of these four loops are ideal to use in different situations.

C Programming Dr. Hasan Demirel

C How to Program, H. M. Deitel and P. J. Deitel, Prentice Hall, 5 th edition (3 rd edition or above is also OK). Introduction to C Programming Dr. Hasan Demirel Programming Languages There are three types

Course learning outcomes

UCS130C/UCS230C COMPUTER CONCEPTS & C PROGRAMMING 4 CREDITS Hrs/Week :04 Total Hrs:48 CIE Marks:50 SEE Marks:50 Course learning outcomes At the end of the course student will be able to: 1. Identify the

A First Book of C++ Chapter 2 Data Types, Declarations, and Displays

A First Book of C++ Chapter 2 Data Types, Declarations, and Displays Objectives In this chapter, you will learn about: Data Types Arithmetic Operators Variables and Declarations Common Programming Errors

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

198:211 Computer Architecture

198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book 1 Computer Architecture What do computers do? Manipulate stored

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL

BACHELOR OF COMPUTER APPLICATIONS SEMESTER -I

BACHELOR OF COMPUTER APPLICATIONS SEMESTER -I Fundamentals and Windows Based Application Understanding Computers Computer: A Definition, Characteristics of Computers, Speed, Accuracy, Diligence, Versatility,

1. Define: (a) Variable, (b) Constant, (c) Type, (d) Enumerated Type, (e) Identifier.

Study Group 1 Variables and Types 1. Define: (a) Variable, (b) Constant, (c) Type, (d) Enumerated Type, (e) Identifier. 2. What does the byte 00100110 represent? 3. What is the purpose of the declarations

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: IMPORTANT INSTRUCTIONS: 1. Question Paper in English and Hindi and Candidate can choose any one language. 2. In case of discrepancies in

1) String initialization can be carried out in the following ways, similar to that of an array :

Strings in C : Overview : String data type is not supported in C Programming. String is essentially a collection of characters to form particular word. String is useful whenever we accept name of the person,

Dept. of CSE, IIT KGP

Programming in C: Basics CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Types of variable We must declare the

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types In this lecture Computer Languages Assembly Language The compiler Operating system Data and program instructions Bits, Bytes and Data Types ASCII table Data Types

UNIT-1. C Programming & Data Structures. Introduction to Computers: Computing Environment: Types of Computing Environments:

Introduction to Computers: C Programming & Data Structures UNIT-1 A computer system consists of hardware and software. Computer hardware is the collection of physical elements that comprise a computer

Common Errors in C. David Chisnall. February 15, 2011

Common Errors in C David Chisnall February 15, 2011 The C Preprocessor Runs before parsing Allows some metaprogramming Preprocessor Macros Are Not Functions The preprocessor performs token substitution

Going from Python to C

Going from Python to C Darin Brezeale December 8, 2011 Python is a high-level, interpreted language. C has many of the same types of programming constructs as in Python: arrays, loops, conditionals, functions,

Tutorial-3a: First steps with C++ programming

HTTP://WWW.HEP.LU.SE/COURSES/MNXB01 Introduction to Programming and Computing for Scientists (2015 HT) Tutorial-3a: First steps with C++ programming Programming for Scientists Tutorial 3a 1 / 17 Quick

BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering

BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering Cohort: BCNS/07/FT- BIS/07/FT- BIS/06/FT -BM/07/FT BSE/07/FT/PT-

UNIT-1 PART-A UNIT-2 PART-A

UNIT-1 1. Define computer? 2. Discuss briefly about input and output devices? 3. What is a RAM? 4. What is arom? 5. What is a compiler? 6. Write about a linker? 7. List any 5 key wordsof c? 8. Illustrate

Programming for MSc Part I

Herbert Martin Dietze University of Buckingham herbert@the-little-red-haired-girl.org July 24, 2001 Abstract The course introduces the C programming language and fundamental software development techniques.

3. BINARY NUMBERS AND ARITHMETIC

3. BINARY NUMBERS AND ARITHMETIC 3.1. Binary Numbers The only place in a computer where you will find the number 9 is on the keyboard. Inside the computer you will only find 0 s and 1 s. All computer memory

Pseudo code Tutorial and Exercises Teacher s Version

Pseudo code Tutorial and Exercises Teacher s Version Pseudo-code is an informal way to express the design of a computer program or an algorithm in 1.45. The aim is to get the idea quickly and also easy

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science Program Schedule CTech Computer Science Credits CS101 Computer Science I 3 MATH100 Foundations of Mathematics and

Unit 3: Algebra. Date Topic Page (s) Algebra Terminology 2. Variables and Algebra Tiles 3 5. Like Terms 6 8. Adding/Subtracting Polynomials 9 12

Unit 3: Algebra Date Topic Page (s) Algebra Terminology Variables and Algebra Tiles 3 5 Like Terms 6 8 Adding/Subtracting Polynomials 9 1 Expanding Polynomials 13 15 Introduction to Equations 16 17 One

Punctuation in C. Identifiers and Expressions. Identifiers. Variables. Keywords. Identifier Examples

Identifiers and Expressions CSE 130: Introduction to C Programming Spring 2005 Punctuation in C Statements are terminated with a ; Groups of statements are enclosed by curly braces: { and } Commas separate

CIS 190: C/C++ Programming. Lecture 1 Introduction and Getting Started

CIS 190: C/C++ Programming Lecture 1 Introduction and Getting Started This course will teach you the basics of C and C++ give you more programming experience be appropriate for majors and non-majors not

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

Mini Projects List

Mini Projects List 1. Develop a mini project in C language using functions to perform the following operations a. Defining a user define function to copy one string into anther string b. Define a user

Objective Type Questions

Objective Type Questions Unit- Introduction to computer and programming: Sr.No. Multiple Choice Question Paper Marks Which of the following is a part of primary memory of computer a) PROM b) CD-ROM c)

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

Repetition and Loops. Additional Python constructs that allow us to effect the (1) order and (2) number of times that program statements are executed.

New Topic Repetition and Loops Additional Python constructs that allow us to effect the (1) order and (2) number of times that program statements are executed. These constructs are the 1. while loop and

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology) Subject Description: This subject deals with discrete structures like set theory, mathematical

The Basics of C Programming. Marshall Brain

The Basics of C Programming Marshall Brain Last updated: October 30, 2013 Contents 1 C programming 1 What is C?................................. 2 The simplest C program, I........................ 2 Spacing

3/13/2012. ESc101: Multiple statement execution using loops. Loops are used when instructions are repeated. while statement can be used for a loop

ESc101: Multiple statement execution using loops Instructor: Krithika Venkataramani Semester 2, 2011-2012 The content of most of these slides are taken from the lecture slides of Prof. Arnab Bhattacharya

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)

Vector and Matrix Norms

Chapter 1 Vector and Matrix Norms 11 Vector Spaces Let F be a field (such as the real numbers, R, or complex numbers, C) with elements called scalars A Vector Space, V, over the field F is a non-empty

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

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 2: Basic Elements of C++

C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with the basic components of a C++ program,

[Page 70 (continued)] a. are used to document a program and improve its readability. [Page 71]

[Page 70 (continued)] Exercises 2.7 Discuss the meaning of each of the following objects: a. std::cin b. std::cout 2.8 Fill in the blanks in each of the following: a. are used to document a program and

Standard printing function in C is printf Prints everything numbers, strings, etc. May be complex to use. Standard C library is called libc

Arrays and Structs and Pointers, Oh My! Programming in C Input and output Using printf Standard input and output Pointers Arrays Structures Combining these things together Arrays and Structs and Pointers,

LabVIEW Day 3: Arrays and Clusters

LabVIEW Day 3: Arrays and Clusters Vern Lindberg By now you should be getting used to LabVIEW. You should know how to Create a Constant, Control, or Indicator. I will assume you know how to create a new

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

LAB 1 REPRESENTATION OF NUMBERS AND INTRODUCTION TO C

LAB 1 REPRESENTATION OF NUMBERS AND INTRODUCTION TO C 1. LAB OBJECTIVE The objective of this lab is to review binary numbers and to review/introduce you to the C programming language and the MATLAB environment.

Programming in Engineering PiE CTW-MSM Exam C/C++ (2012)

1 Programming in Engineering PiE CTW-MSM 191158510 Exam C/C++ (2012) 2 Instructions Present your results in a report that includes a short explanation of your approach, answer to the questions, what you

Geometric Series. On the other hand, if 0 <r<1, then the exponential function of base r, the function g(x) =r x, has a graph that looks like this:

Geometric Series In the previous chapter we saw that if a>, then the exponential function with base a, the function f(x) =a x, has a graph that looks like this: On the other hand, if 0

Logic Design. Dr. Yosry A. Azzam

Logic Design Dr. Yosry A. Azzam Binary systems Chapter 1 Agenda Binary Systems : Binary Numbers, Binary Codes, Binary Logic ASCII Code (American Standard Code for Information Interchange) Boolean Algebra

INTRODUCTION TO FLOWCHARTING

CHAPTER 1 INTRODUCTION TO FLOWCHARTING 1.0 Objectives 1.1 Introduction 1.2 Flowcharts 1.3 Types of Flowcharts 1.3.1 Types of flowchart 1.3.2 System flowcharts 1.4 Flowchart Symbols 1.5 Advantages of Flowcharts

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

OUTCOMES BASED LEARNING MATRIX

Course: CTIM371 Programming in C++ OUTCOMES BASED LEARNING MATRIX Department: Computer Technology and Information Management Course Description: This is the first course in the C++ programming language.

Introduction Number Systems and Conversion

UNIT 1 Introduction Number Systems and Conversion Objectives 1. Introduction The first part of this unit introduces the material to be studied later. In addition to getting an overview of the material

5-6 The Remainder and Factor Theorems

Use synthetic substitution to find f (4) and f ( 2) for each function. 1. f (x) = 2x 3 5x 2 x + 14 Divide the function by x 4. The remainder is 58. Therefore, f (4) = 58. Divide the function by x + 2.

Exercise 4 Logical Operators & Branching

Exercise 4 Logical Operators & Branching Informatik I für D-MAVT (FS 2013) Christian Schumacher chschuma@inf.ethz.ch Agenda Branching relational operators logical expressions: and, or, not if, else if,

b) lower case always use lower case for all matlab commands. This is what matlab recognizes.

1 Matlab 1) Fundamentals a) Getting Help for more detailed help on any topic, typing help, then a space, and then the matlab command brings up a detailed page on the command or topic. For really difficult

KENDRIYA VIDYALAYA TIRUMALAGIRI HOLIDAY HOMEWORK CLASS XII COMPUTER SCIENCE (083) C++ Practice Problems

(i).there are 39 problems. KENDRIYA VIDYALAYA TIRUMALAGIRI HOLIDAY HOMEWORK CLASS XII COMPUTER SCIENCE (083) C++ Practice Problems 1. What is the exact output of the program below? Indicate a blank space

Vector storage and access; algorithms in GIS. This is lecture 6

Vector storage and access; algorithms in GIS This is lecture 6 Vector data storage and access Vectors are built from points, line and areas. (x,y) Surface: (x,y,z) Vector data access Access to vector

UNIT III: 1. What is an array? How to declare and initialize arrays? Explain with examples

UNIT III: Arrays: Introduction, One-dimensional arrays, Declaring and Initializing arrays, Multidimensional arrays. Strings: Introduction to Strings, String operations with and without using String handling

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

C Syntax and Semantics

C Syntax and Semantics 1 C Program Structure C Language Elements Preprocessor directives Function Header, and Function body Executable statements Reserved word, Standard identifiers, user defined identifiers

IEEE floating point numbers. Floating-Point Representation and Approximation. floating point numbers with base 10. Errors

EE103 (Shinnerl) Floating-Point Representation and Approximation Errors Cancellation Instability Simple one-variable examples Swamping IEEE floating point numbers floating point numbers with base 10 floating

SEARCHING AND SORTING

SEARCHING AND SORTING Searching A basic operation in computer science Problem formulation Given: Collection (array) of values A property on values Find: a value having the property in the array Examples