COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Slides:



Advertisements
Similar presentations
Sort the given string, without using string handling functions.
Advertisements

1 Class Vehicle #include #define N 10../.. 2 Class Vehicle class vehicle { public: float speed; char colour[N+1]; char make[N+1];
Functions in C++. Functions  Groups a number of program statements into a unit & gives it a name.  Is a complete and independent program.  Divides.
Appendix Lab Manual for Programming Skills 1. Symbols used in Writing Programs { opening curly bracket } closing curly bracket # hash sign or number sign.
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.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
Outlines Chapter 3 –Chapter 3 – Loops & Revision –Loops while do … while – revision 1.
LECTURE 11 TYPES OF USER DEFINE FUNCTIONS ITC-414.
Perimeter = 2*(length+width)
Computer Science Department LOOPS. Computer Science Department Loops Loops Cause a section of your program to be repeated a certain number of times. The.
Chapter 3. Outline Relational Operators Loops Decisions Logical Operators Precedence Summary.
LOOP & Type Conversion. do – while Loop In the while loop, the test expression is evaluated at the beginning of the loop. If the test condition is false.
String functions+ string I.Mona Alshehri. String Functions: Header file:#include Function: Int strlen(char s[n]) Description Calculates the length of.
Computer Programming Control Structure
Statements
CS1201: PROGRAMMING LANGUAGE 2 FUNCTIONS. OVERVIEW What is a Function? Function Prototype Vs Decleration Highlight Some Errors in Function Code Parameters.
XII CBSE Previous Year Question Paper QUESTION NO 1 (F) 2 or 3 Marks.
Course Title Object Oriented Programming with C++ Course instructor ADEEL ANJUM Chapter No: 04 loops 1 BY ADEEL ANJUM ( MSc - cs, CCNA, WEB DEVELOPER )
Unary Not operator !  !true = false  !false = true.
Exception Handling How to handle the runtime errors.
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.
Asif Nawaz University Institute of Information Technology, PMAS-AAUR Lecture 05: Object Oriented Programming:2014 Object-Oriented Programming in C++ Exception.
C++ CODES PART#04 1 COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT.
The Repetition control structure using while loop.
Computer Programming -1-
INPUT & OUTPUT 10/20/2016Department of Computer Science, UOM | Introduction | Fakhre Alam.
WHILE, DO-WHILE AND FOR LOOPS
LESSON 2 Basic of C++.
Intro to Programming Week # 6 Repetition Structure Lecture # 10
Operator Overloading.
CSC113: Computer Programming (Theory = 03, Lab = 01)
Introduction to C++.
Intro to Programming Week # 4 Switch Statement Lecture # 7
CSC113: Computer Programming (Theory = 03, Lab = 01)
JUMP STATEMENT C++ has the four statements that perform an unconditional branch. They are, 1. return 2. goto 3. break 4. continue In addition to four statements.
Intro to Programming Week # 5 Repetition Structure Lecture # 9
Programming fundamentals 2 Chapter 2:Function
Tejalal Choudhary “C Programming from Scratch” Pointers
Visit for more Learning Resources
ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Ambiguity Resolution in Inheritance
Intro to Programming Week # 3 If-else Statement Lecture # 6
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Compound Assignment Operators in C++
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Screen output // Definition and use of variables
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Passing objects As arguments
Lecture 12 Oct 16, 02.
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Default Arguments.
Dr. Khizar Hayat Associate Prof. of Computer Science
Function Overloading.
Name: Muhammad Hassan VU-ID: BC Version: Office 2007
Introduction to Algorithms and Programming
Dr. Khizar Hayat Associate Prof. of Computer Science
ENGR.SABA MUGHAL FROM COMPUTER SYSTEM DEPARTMENT
CPP Programming Language
TOPIC: FUNCTION OVERLOADING
ENGR.SABA MUGHAL FROM COMPUTER SYSTEM DEPARTMENT
Introduction to Algorithms and Programming COMP151
Course Outcomes of Programming In C (PIC) (17212, C203):
Programming Fundamental
Programming Fundamental
Functions Chapter No. 5.
Programming Fundamental-1
Presentation transcript:

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT C++ CODES PART#06 COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Calculate area of a circle using a=pi*r*r #include<iostream.h> #include<conio.h> void main() { clrscr(); float rad; const float pi=3.14159f; cout<<"Enter Radious :"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE… cin>>rad; float area=pi*rad*rad; cout<<"Area is :"<<area<<endl; getch(); } COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Do While loop #include<constream.h> void main() { clrscr(); int a; a=1; do COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONTINUE…. { cout<<a<<endl;a++; } while (a<11); getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output… COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Using power function #include<constream.h> #include<math.h> void main() {clrscr(); int a,b,c; cout<<"enter the limit upto where you want the series"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue…. cin>>a; for(b=1;b<=a;b++) {c=pow(b,2); cout<<c<<" ";} cout<<"this series is the required one"; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output… COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Generate series as shown in the output… #include<constream.h> #include<math.h> void main() {clrscr(); int a,b,c; cout<<"enter limit"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue… cin>>a; for(b=1;b<=a;b++) {c=2*b*pow(-1,b); cout<<c<<" ";} cout<<"this series is the required one"; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Generate series as shown in the output… #include<constream.h> #include<math.h> void main() {clrscr(); int a,b,c; cout<<"enter the last limit"; cin>>a; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue…. for(b=1;b<=a;b++){ c=2*b*pow(-1,b+1); cout<<c<<" ";} cout<<"hence this is the required series"; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Generate series as shown in the output… #include<constream.h> #include<math.h> void main() {clrscr(); int a,b,c; cout<<"enter the last limit"; cin>>a; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue….. for(b=0;b<=a;b++) {c=pow(3,b); cout<<c<<" ";} cout<<"this series is the required one"; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT While loop #include<constream.h> void main() {clrscr(); int n; while(n!=0) cin>>n; cout<<endl; getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output….. User enters many numbers when he/she enters zero so program terminates COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Generate series as shown in output using while loop #include<constream.h> #include<math.h> void main() { clrscr(); int a,b,r; cout<<"plz enter your limit"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue…. cin>>b; a=1; while(a<=b) {r=2*a*pow(-1,a+1); cout<<r<<" "; a++;} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Generate series as shown in output using while loop #include<constream.h> #include<math.h> void main() {clrscr(); int a,b,r; cout<<"enter limit"; cin>>b; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue…. a=0; while(a<b) {r=pow(3,a); cout<<r<<" "; a++;} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output…. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

Generate series as shown in output using while loop #include<constream.h> #include<math.h> void main() { clrscr(); int a,b,r; cout<<"enter the limit"; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue… cin>>b; a=1; while (a<=b) {r=pow(a,2); cout<<r<<" "; a++;} getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Do-while loop #include<constream.h> void main() {clrscr(); long dividend,divisor; char ch; do { COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue… cout<<"enter dividend:"; cin>>dividend; cout<<"enter divisor:"; cin>>divisor; cout<<"quotient is "<<dividend/divisor; COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Continue…. cout<< " , remainder is "<<dividend%divisor; cout<<" \n do another?(y/n):"; cin>>ch;} while (ch!='n'); getch();} COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT Output….. COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT

COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT CONCLUSION NICE WORDINGS…. It is more difficult to stay on top than to get there. The secret of success is that we never, never give up Barish ka Qatra Seepi or Sanp dono kay Munah mein girta hai Jab keh Sanp ussay Zehar bana deta hai aur Seep Usay Moti. Jis ka jaisa "Zarf" waisi Uss ki "Takhleeq" . COPY RIGHT@ ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT