Faculty: Pushpendra K Rajput Session:

Similar documents
SHARDA UNIVERSITY SCHOOL OF ENGINEERING & TECHNOLOGY Mid Term Examination, (Odd Term, ) SOLUTION

Faculty: Pushpendra K Rajput Session:

UNIVERSITY OF WINDSOR Fall 2006 QUIZ # 1. Examiner:Ritu Chaturvedi Dated : Oct 3rd, Student Name: Student Number:

CpSc 1111 Lab 9 2-D Arrays

CpSc 111 Lab 3 Integer Variables, Mathematical Operations, & Redirection

Variables, Data Types, and Arithmetic Expressions Learning Objectives:

provided. Use any other space for rough work. The question paper has total 8 pages. Rough Work

UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution. Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number:

Copy: IF THE PROGRAM or OUTPUT is Copied, then both will have grade zero.

CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection

M. Tech. (Power Electronics and Power System) (Semester I) Course Plan for Each Week (Hrs)

M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

Lab 2: Structured Program Development in C

Chapter 3 Structure of a C Program

Pointers and Arrays 1

School of Computing & Information Technology. Department of Computer Science & Engineering LAB MANUAL CS-1331 DATA STRUCTURES LAB

Operators & Expressions

Expressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators

York University Faculty Science and Engineering Fall 2008

CSE123 LECTURE 3-1. Program Design and Control Structures Repetitions (Loops) 1-1

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

Quiz1 Fall 2007 October 2 nd, UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated :October 2nd, 2007.

Chapter 3 Structured Program Development

Fortran 90 Two Commonly Used Statements

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto

CpSc 1011 Lab 11 Pointers

Exponential Notation

Sir Syed University of Engineering and Technology. Computer Programming & Problem Solving ( CPPS )

Pointer in C SHARDA UNIVERSITY. Presented By: Pushpendra K. Rajput Assistant Professor

Class 9 Saturday, Feb 14

ASSIGNMENT BOOKLET. M.Sc.(Mathematics with Applications in Computer Science) Programming and Data Structures (1 st January, 2018 December, 2018)

Variables and Operators 2/20/01 Lecture #

50 MATHCOUNTS LECTURES (6) OPERATIONS WITH DECIMALS

Boca Raton Community High School AP Computer Science A - Syllabus 2009/10

School of Computer Science Introduction to Algorithms and Programming Winter Midterm Examination # 1 Wednesday, February 11, 2015

Functions. Arash Rafiey. September 26, 2017

Unit 3 Decision making, Looping and Arrays

(Following Paper ID and Roll No. to be filled by the student in the Answer Book)

UNIVERSITY OF WINDSOR Winter 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated : Feb 7 th, Student Name: Student Number:

What we have learned so far

M1-R4: Programing and Problem Solving using C (JAN 2019)

In Fig. 3.5 and Fig. 3.7, we include some completely blank lines in the pseudocode for readability. programs into their various phases.

60th ANNUAL HIGH SCHOOL HONORS MATHEMATICS CONTEST

Pointers (part 1) What are pointers? EECS We have seen pointers before. scanf( %f, &inches );! 25 September 2017

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

MA 511: Computer Programming Lecture 3: Partha Sarathi Mandal

CSE 115 Programming Language I Final Examination Fall 2015

BSc (Hons) Computer Science. with Network Security. Examinations for / Semester1

Operators and Expressions:

9/10/2016. Time for Some Detailed Examples. ECE 120: Introduction to Computing. Let s See How This Loop Works. One Statement/Step at a Time

Fundamentals of Programming Session 7

CSE 215: Foundations of Computer Science Recitation Exercises Set #4 Stony Brook University. Name: ID#: Section #: Score: / 4

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

Flow Chart. The diagrammatic representation shows a solution to a given problem.

H192 Midterm 1 Review. Tom Zajdel

Note: unless otherwise stated, the questions are with reference to the C Programming Language. You may use extra sheets if need be.

Worksheet 4 Basic Input functions and Mathematical Operators

A complex expression to evaluate we need to reduce it to a series of simple expressions. E.g * 7 =>2+ 35 => 37. E.g.

OBJECT ORIENTED PROGRAMMING

Pre-Algebra Notes Unit One: Rational Numbers and Decimal Expansions

The Hyderabad Public School, Begumpet, Hyderabad, A.P

Using only 1, 2 and 3, and the rules of the 3-number challenge, show how we could use addition only or multiplication only to arrive at 6.

Government Polytechnic Muzaffarpur.

AMCAT Automata Coding Sample Questions And Answers

sends the formatted data to the standard output stream (stdout) int printf ( format_string, argument_1, argument_2,... ) ;

MA 511: Computer Programming Lecture 2: Partha Sarathi Mandal

3. EXPRESSIONS. It is a sequence of operands and operators that reduce to a single value.

Basics of Programming

CSI33 Data Structures

Computer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size];

3/13/2012. ESc101: Introduction to Computers and Programming Languages

Pre-Algebra Notes Unit Five: Rational Numbers and Equations

Pre-Algebra Notes Unit Five: Rational Numbers and Equations

COMP Assignment 1

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Reg. No. : Question Paper Code : B.E./B.Tech. DEGREE EXAMINATION, JANUARY First Semester GE 6151 COMPUTER PROGRAMMING

Arrays in C. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

Chapter 2, Part III Arithmetic Operators and Decision Making

EC312 Chapter 5: Intro to Pointers

LOOPS. 1- Write a program that prompts user to enter an integer N and determines and prints the sum of cubes from 5 to N (i.e. sum of 5 3 to N 3 ).

Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1

3.3 Structures. Department of CSE

to calculate Fib(N) very quickly 1 Task 1: High-school algebra helps to design your program

Lab Session # 1 Introduction to C Language. ALQUDS University Department of Computer Engineering

BRANCHING if-else statements

CMPE Experiment 3 Selective Structures

Variable and Data Type I

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

Kadi Sarva Vishwavidyalaya, Gandhinagar

Questions Bank. 14) State any four advantages of using flow-chart

B. Subject-specific skills B1. Problem solving skills: Supply the student with the ability to solve different problems related to the topics

Week 3: Objects, Input and Processing

CSE101-Lec#18. Multidimensional Arrays Application of arrays. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU. LPU CSE101 C Programming

Multiple Choice Questions ( 1 mark)

Review Functions. Natural Language and Dialogue Systems Lab

Pick any positive integer. If the integer is even, divide it by 2. If it is odd,

Advanced Algebra I Simplifying Expressions

CSE 115. Introduction to Computer Science I

Timing for Ripple Carry Adder

Formatting for TLM - Part I

Transcription:

Department of Computer Science and Engineering School of Engineering and Technology Lab Sheet. 1 & 2 Given Date: 6 th September, 2016 Subject: Advanced Concepts of C Programming Code: CSE-110 Program/Branch: B.Tech/CSE,ME Term/Sec: I/B,A Faculty: Pushpendra K Rajput Session: 2016-2017 Week-1: 6 th September, 2016-11 th September,2016 Note:- Students are supposed to make a separate notebook for Lab Record that S/He has to submit in End-Semester examination for the same Lab. All the programs should be written in your Lab Notebook in the format given in secttions How to solve?. No copied materials will be accepted. Problem-1: Do analyze the following segments of code on your notebook and write conclusion about it. 1.1 #inlclude<stdio,h> printf( Author Name: \n ); printf( B. Tech. 1 st Year\t Section: ); printf( \ndate: \n ); printf( C seems interesting if I practice daily ); printf( \n /n/n \n\n ); printf( 1234\r456789\r00 ); printf( \n\n/n/n/n ); Conclusion: Clearly mention the use of \n \t and \r 1.2 #inlclude<stdio,h> int a,b,c,d; float w,x,y,z; printf( Enter Four integer Values ); scanf( %d%d%d%d,&a,&b,&c,&d); printf( Enter Four floating point value ); scanf( %f%f%f%f,&w,&x,&y,&z); c = a/b; y = a/b;

c = w/x; y = w/x; c = a/x; y = w/b; c = d/3; y = d/3; c = d/3.0; y = d/3.0; c = z/3; y = z/3; c = z/3.0; y = z/3.0; Conclusion: Clearly mention the use of getch() and use of different type of value in an expression (How result is depending on these type) 1.3 #inlclude<stdio,h> int a,b,c,d; a = 7 % 2; b = 23 % -2; c = -53 % 5; d = -34 % -9; printf( a = %d\nb = %d\nc = %d\nd = %d,a,b,c,d); Conclusion: Clearly mention meaning of % operator and also write the sign of result depends on numerator or denominator. 1.4 #inlclude<stdio,h> int a=2, b=3,c=4,d=5,e; float m = 6.0,n = 7.5, p = 1.5,q; e = a / b + c * d;

printf( e = %d\n,e); e = a * b c % (d + a) / b; printf( e = %d\n,e); e = a + m / b c * d; printf( e = %d\n,e); q = a + m / (b c) * d; printf( q = %f\n,q); e = m * n / a c % d * p d; q = c * b / a a % b * p d; printf( e = %f\n,e); printf( q = %f\n,q); Conclusion: Define priority of arithmetic operators 1.5 Write a program in C to calculate average of three numbers. Expected Output: Average of, & is = Problem-2: Write following program in C. 2.1 This problem's challenge is to create each numeric value from 0 to 9 using only four fours!.you are supposed to write 9 different statements similar to following each for one digit printf( Zero is %d,4+4-4-4) Output will be:- Zero is 0 Expected Output: Zero is 0 One is 1 Two is 2 Three is 3 Four is 4 Five is 5 Six is 6 Seven is 7 Eight is 8 Nine is 9 2.2 Write a program that will multiply each digit by 2 of a 4 digit number and map it between 0 and 9 according to following mapping: Calculated Digit 0 2 4 6 8 10 12 14 16 18 Mapped Digit 0 2 4 6 8 0 2 4 6 8 Expected Output: Number after Mapping = Example: Input: 6489 Expected Output: Number after Mapping = 2868

How to solve a problem? Students are advised to follow following approach to complete any Lab problem: Step1: Read Problem statement carefully. Step2:Analyze your problem: (a) Think about Input Requirement: Type of Values, Possible Values, etc. (b) Think about Output Requirement: Type, Format, etc. (c) Think about Process Step3: Develop your Algorithms (Process steps) Step4: Implement your solution on computer. Step5: Compile and resolve errors if any. Step6: Execute your program and get output. Step7: Compare with desired output. Step8: Refine solution if required to get desired output. Step9: Write your Solution in your Lab Record (Flow Chart and C Program only). Exapmle: Problem: Write a program in C that will convert a given number of seconds into equivalent time in terms of Hours, Minutes and seconds. Expecteed Output: Duration = : : How to Write in Lab Notebook: Problem Statement: Write a program in C that will convert a given number of seconds into equivalent time in terms of Hours, Minutes and seconds. Solution: Input : Number of seconds Output: Hrs:Min:Seconds

Flow Chart: Start Input S Hrs = S / 3600 R = S % 3600 Mins = R / 60 Scnds = R % 60 Hrs:Mins:Scnds Stop C Program: /* Programmer Name:------------ Date:----------- Lab Sheet No.:------------- Problem No:--------------*/ #include<stdio.h> //Declare all required variables int Seconds, Hrs, Mins, Scnds, R; //Receive input from user printf( Enter Number of Seconds ); scanf( %d, &seconds); //calculate Hrs, Mins, and Seconds

Hrs = seconds / 36000//return quotient as integer division R = seconds % 3600; Mins = R / 60; Scnds = R % 60; Printf( Duration = %d:%d:%d,hrs,mins,scnds); OUTPUT: Enter Number of Seconds 40000 Duration = 11:6:40