Dr. Faiyaz Gadiwalla Hinduja College. Q 2 A) a) Wages calc. b) Sort c) Output Q3 A) a) Series b) Display result c) Output.

Slides:



Advertisements
Similar presentations
#include void main() { float x = 1.66, y = 1.75; printf(%f%f,ceil(x), floor(y)); }
Advertisements

Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
Unit 2 The if-else-if LECTURE – 14
1 CSC103: Introduction to Computer and Programming Lecture No 8.
5/17/ Programming Constructs... There are several types of programming constructs in JAVA. - If-else construct or ternary operator - while - do-while.
A program example is given below to input date and display on the screen by write a class ‘ date ‘ # include Class date { Private: Int y, m, d ; Publice.
Function with Output Parameters 4 We have seen that functions can return a single value or no value (void return type) 4 It is quite often useful to be.
Multidimensional Arrays. Example Write a program to keep track of all warmup scores for all students. Need a list of a list of scores Student – score.
1 Arithmetic in C. 2 Type Casting: STOPPED You can change the data type of the variable in an expression by: (data_Type) Variable_Name Ex: int a = 15;
If () else statement, switch statement, while () loop, do…while() loop and for( ; ; ) loop 1.
CMSC 104, Version 8/061L22Arrays1.ppt Arrays, Part 1 of 2 Topics Definition of a Data Structure Definition of an Array Array Declaration, Initialization,
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
 Introduction Introduction  Types of Function Types of Function  Library function Library function  User defined function User defined function 
Lecture 6 – Functions (2). Outline Recall - sample application functions that return no value functions that return a value Recall – global variable vs.
CP104 Introduction to Programming Selection Structures_3 Lecture 11 __ 1 The Switch Statement The switch statement provides another means to select one.
Selection Statements in C++ If Statement in C++ Semantics: These statements have the same meaning as in the algorithmic language. 2- Two way selection:
IF-ELSE IF-ELSE STATEMENT SWITCH-CASE STATEMENT Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
Selection Structures (if & switch statements) (CS1123)
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 9 – Income Tax Calculator Application: Introducing.
Chapter 4: Making Decisions. Resource: Starting Out with C++, Third Edition, Tony Gaddis 4.1 Relational Operators Relational operators allow you to compare.
A Program is nothing but the execution of sequence of one or more Instructions. On the basis of application it is essential. To Alter the flow of a program.
1 CSC103: Introduction to Computer and Programming Lecture No 7.
Lecture 3 Decisions (Conditionals). One of the essential features of computer programs is their ability to make decisions. Like a train that changes tracks.
UniMAP SemII-09/10EKT120: Computer Programming1 Week 6 – Functions (2)
1 Programming 2 Overview of Programming 1. Write the equations in C++ notation : a) R =   a + b  24  2 a  b) W = a 12 + b 2 – 2abcos(y) 2a.
Struct 1. Definition: Using struct to define a storage containing different types. For example it can contain int, char, float and array at the same time.
How to design and code functions Chapter 4 (ctd).
Problems Reads a letter grade from user and displays the corresponding range for that letter grade (A  , B  80-89, C  70-79, D  60-69, otherwise.
Structured Programming (4 Credits) HNDIT Week 2 – Learning Outcomes Design an algorithmic solution for simple problem such as computation of a factorial,
CSCI 171 Presentation 3. Operators Instructs C to perform some operation Assignment = Mathematical Relational Logical.
Repetition Repetition allows you to repeat an operation or a series of operations many times. This is called looping and is one of the basic structured.
1 Original Source : and Problem and Problem Solving.ppt.
Review (before the 1 st test): while (conditions) { statements; } while loop: if/else if/else statements: if (conditions) { statements; } else if (different.
QUESTIONS IN SPREADSHEET Dr. Faiyaz Gadiwalla Hinduja College.
Agenda  Basic Logic - Continued...  if else statements  switch Statements  Compound Conditions.
Selection Control Structures 2 (L09) * Nested if Statements * The if-else Chain * Exercise: if, if-else, nested if, and if-else chain Selection Control.
IT CS 200: R EPEATATION Lect. Napat Amphaiphan. T HE ABILITY TO DO THE SAME TASK AGAIN BY AGAIN UNTIL THE CONDITION IS MET LOOP 2.
NOTE: C programs consist of functions one of which must be main. C programs consist of functions one of which must be main. Every C program begins executing.
Making Decisions in c. 1.if statement Imagine that you could translate a statement such as “If it is not raining, then I will go swimming” into the C.
FLOW OF CONTROL In C++ the program execution starts with the first statement in the main() and ends with the last statement of main(). This is called.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
More on conditional statements. Conditionals In some situations the typical if-else statements may become cumbersome Depending on the situation, there.
Strings C supports strings using one-dimensional character arrays. A string is defined as a null-terminated character array. In C, a null is 0. You must.
THE DECISIONS CONTROL STRUCTURE! CHAPTER 2. Transfer of control statement: o The statement of computer program are executed one after the other in the.
Rules for Constructing Variable Names
‘C’ Programming Khalid Jamal.
EKT120 COMPUTER PROGRAMMING
EKT150 INTRODUCTION TO COMPUTER PROGRAMMING
EKT120: Computer Programming
Decisions Chapter 4.
EKT150 INTRODUCTION TO COMPUTER PROGRAMMING
Relational Operators A relational operator compares two values. The values can be any built-in C++ data type, such as Character Integer Floating point.
Week 3 – Selection Structures
FUNCTIONS EXAMPLES.
Control Statement Examples
Looping.
Arrays, Part 1 of 2 Topics Definition of a Data Structure
אבני היסוד של תוכנית ב- C
محاضرة 1: مقدمة للمسـاق و مراجعـة للأساسيـات
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Chapter 2.1 Repetition.
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Computer Programming Techniques Semester 1, 1998
Arrays, Part 1 of 2 Topics Definition of a Data Structure
CPS125 Week 5.
More on conditional statements
Introduction to Problem Solving and Programming
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Switch Case Structures
Presentation transcript:

Dr. Faiyaz Gadiwalla Hinduja College

Q 2 A) a) Wages calc. b) Sort c) Output Q3 A) a) Series b) Display result c) Output

C LANGUAGE : SEM VI Typical Questions Q 2 A) a) Sales Tax b) DA, HRA c) Output Q3 A) a) Series b) Depreciation c) Theory

C LANGUAGE : SEM VI What is the output of the following C program? #include void main() { int x=1,y=10,z=5; float s=0; x++; y+=x++*z; z--; s+=x/y; printf("\n%d %d %d\n",x,y,z); printf("%f\n",s); }

C LANGUAGE : SEM VI Write a program to input the marks of a student in three subjects and calculate the total and average marks. Display the result of the student along with the total and average marks where the result is ‘Pass” if the student gets 35 or more marks in each subject, otherwise result is “Fails” #include void main() { float m1,m2,m3,tm,avg; printf(“Enter the marks in 3 subjects\n”); scanf(“%f %f %f”,&m1,&m2,&m3); tm=m1+m2+m3; avg=tm/3; printf(“Total marks = %.2f and Average marks = %.2f\n”,tm,avg); if(m1>=35 && m2>=35 && m3>=35) printf(“Passes\n”); else printf(“Fails\n”); }

C LANGUAGE : SEM VI Write a program in C to accept sales from the keyboard and calculate and display sales tax as per the following:SALESSALES TAX upto Rs 5,0005% of sales between Rs 5000 and upto Rs % of sales Over Rs % of sales Note: Here the sales tax is to be calculated as a flat rate of the Sales. #include void main() { float s,st; printf(“Enter the sales “); scanf(“%f”,&s); if(s<=5000) st=s*.05; else if(s>5000 && s<=9000)/*we can also just write else if(s<=9000) */ st = s*.10; else st = s*.12; pritnf(“Sales Tax = %.2f\n”,st); }

C LANGUAGE : SEM VI Write a Program in C to input the Name, grade and basic salary of an employee of a factory and calculate the Bonus using the switch statement. Display the Name and bonus where Grade Bonus A 50% of Basic B 60% of Basic C 70% of Basic Rest 80% of Basic #include void main() { char n[20]; char gr; float bs, b; printf(“Enter name, grade and basic pay “); scanf(“%s %c %f”, n, &gr, &bs); switch(gr) { case ‘A’: b = bs*.50; break; case ‘B’: b= bs*.60; break; case ‘C’: b= bs*.70; break; default: b= bs*.80; break; } printf(“Name = %s\n”, n); printf(“Bonus = %.2f\n”, b); }