Aim : To Write a C++ Program that prints a Fibonacci series

Similar documents
«ï è : Fibonacci ªî ì ó Ü C C++ Gó ô â î. Pº ø : àœk : Enter the value of N : 5. ªõOf : Fibonacci Series. «ï è : ªî ì ªð ¼ è ô è ìp» C++ Gó ô â î

1. FIBONACCI SERIES. Write a C++ program to generate the Fibonacci for n terms. To write a C++ program to generate the Fibonacci for n terms.

---

COMPUTER SCIENCE PRACTICAL GUIDE [ ENGLISH MEDIUM ]

Chapter-6 Classes and Objects. stud.execute(); getch();} Output:

Scheme G. Sample Test Paper-I. Course Name : Computer Engineering Group Course Code : CO/CD/CM/CW/IF Semester : Second Subject Tile : Programming in C

Object Oriented Programming Using C++ Mathematics & Computing IET, Katunayake

Columns A[0] A[0][0] = 20 A[0][1] = 30

'C' Programming Language

BCSE1002: Computer Programming and Problem Solving LAB MANUAL

MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI

Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013

I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK a) What is the difference between Hardware and Software? Give one example for each.

MA 511: Computer Programming Lecture 3: Partha Sarathi Mandal

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition)

Question Bank (SPA SEM II)

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #04

AMCAT Automata Coding Sample Questions And Answers

PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE

Introduction to Programming (Java) 4/12

CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Chapter 4: Repetition Control Structure

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

CHAPTER 4 FUNCTIONS. 4.1 Introduction

Subject: Computer Science

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

WAP 10. WAP 11. WAP 12. WAP 13. WAP 14. WAP 15. WAP 16. WAP 1. : 17. WAP 18. WAP 19. WAP 20. WAP 21. WAP 22. WAP 23. WAP & 24. WAP

Subject: Fundamental of Computer Programming 2068

22316 Course Title : Object Oriented Programming using C++ Max. Marks : 70 Time: 3 Hrs.

Write a C program using arrays and structure

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #05

STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY

Sample Paper Class XI Subject Computer Sience UNIT TEST II

Chapter 10. Arrays and Strings

CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad

Structured programming

CS101 Computer Programming and Utilization

PDS Lab (Assignment 1) Date: 31 st July, 2017 (2-6 pm)

(6) The specification of a name with its type in a program. (7) Some memory that holds a value of a given type.

F.E. Sem. II. Structured Programming Approach

Programming Assignment 3

ASSIGNMENT CLASS-11 COMPUTER SCIENCE [C++]

1. Basics 1. Write a program to add any two-given integer. Algorithm Code 2. Write a program to calculate the volume of a given sphere Formula Code

KENDRIYA VIDYALAYA ALIGANJ SHIFT-II HOLIDAY HOME WORK XII COMPUTER SCIENCE ARRAY AND STRUCTURES

ESC101N: Fundamentals of Computing End-sem st semester

CPS 101 Introduction to Computational Science

Programming Fundamentals II (C++ II) Final Exam June 17 th, Sun, 2007

What is recursion? Recursion. How can a function call itself? Recursive message() modified. Week 10. contains a reference to itself.

Sample Paper - II Subject Computer Science

2. ARRAYS What is an Array? index number subscrip 2. Write array declarations for the following: 3. What is array initialization?

REPETITION CONTROL STRUCTURE LOGO

Suggestive List of C++ Programs

One Dimension Arrays 1

Q1 (15) Q2 (15) Q3 (15) Q4 (15) Total (60)


C PROGRAMMING. Prof. (Dr.) S. N. Mishra (Prof. & Head, Dept. of CSEA, IGIT, Sarang)

PROGRAMMING IN C AND C++:

CSCE 110 Dr. Amr Goneid Exercise Sheet (7): Exercises on Recursion

A Freshman C++ Programming Course

F.E. Sem. II. Structured Programming Approach

Arrays. Arrays are of 3 types One dimensional array Two dimensional array Multidimensional array

CHAPTER 4 FUNCTIONS. Dr. Shady Yehia Elmashad

Write a program that displays all the even integers between 1 and 100, inclusive

Algorithms 4. Odd or even Algorithm 5. Greatest among three numbers Algorithm 6. Simple Calculator Algorithm

Matrices. Jordi Cortadella Department of Computer Science

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANGULATHUR

Recursion. Example R1

MODULE 2: Branching and Looping

Q1 (15) Q2 (15) Q3 (15) Q4 (15) Total (60)

4(a) ADDITION OF TWO NUMBERS. Program:

Lecture 2. Examples of Software. Programming and Data Structure. Programming Languages. Operating Systems. Sudeshna Sarkar

m) sin() n) endl o) getch() p) cout

CS 177. Lists and Matrices. Week 8

Downloaded S. from Kiran, PGT (CS) KV, Malleswaram STRUCTURES. Downloaded from

C++ Final Exam 2017/2018

OOP THROUGH C++(R16) int *x; float *f; char *c;

Object Oriented Pragramming (22316)

VOLUME II CHAPTER 9 INTRODUCTION TO C++ HANDS ON PRACTICE PROGRAMS

Practical List of. MCA IV SEM Session -2010

/* Area and circumference of a circle */ /*celsius to fahrenheit*/

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak

INTERNATIONAL INDIAN SCHOOL, RIYADH. Ch 1 C++ Revision tour

Computer Programming. Decision Making (2) Loops

Topics: Material through example 19 (types, operators, expressions, functions, selection, loops, arrays)

F.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C

(a) Differentiate between a call by value and call by reference method.

Review Questions for Final Exam KEY

UNIT I : OVERVIEW OF COMPUTERS AND C-PROGRAMMING

PART I. Answer all questions in this Part. While answering questions in this Part, indicate briefly your working and reasoning, wherever required.

Computer Programming

Basic Statements in C++ are constructed using tokens. The different statements are

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

(3) Some memory that holds a value of a given type. (8) The basic unit of addressing in most computers.

Time: 3 HOURS Maximum Marks: 100

I Mid Semester May 2012 : Class XII : Computer Science Max Mark 50 : Time 2 Hrs. 1. a) What is macro in C++? Give example 2

- HALF YEARLY EXAM ANSWER KEY DEC-2016 COMPUTER SCIENCE ENGLISH MEDIUM

C++ PROGRAMMING SKILLS Part 2 Programming Structures

Review. Topics. Lecture 3. Advanced Programming Topics. Review: How executable files are generated. Defining macros through compilation flags

CS 223: Data Structures and Programming Techniques. Exam 2

& Technology. Expression? Statement-x. void main() int no; scanf("%d", &no); if(no%2==0) if(no%2!=0) Syllabus for 1. of execution of statements.

Transcription:

Ex:B1 Fibonacci Series Aim : To Write a C++ Program that prints a Fibonacci series #include <iostream.h> int f1 = -1, f2=1, f3, n, i; cout < < "\n\nenter the value of N : "; cin >> n ; cout < < "\n\nfibonacci Series\n"; for(i=1; i <= n; i++) f3=f1+f2; cout < < "\t" < < f3; f1=f2; f2=f3; Input : Enter the value of N : 5 Ex:B2 Fibonacci Series 0 1 1 2 3 Factorial Value Aim : To Write a C++ Program that finds Factorial Value #include <iostream.h> long factorial(int n) long f=1; int i; for(i=1; i <= n; i++) f = f*i; return f;

int m; cout < < "\nenter the value of M : "; cin >> m ; cout < < "\n\nm = " < < m; cout < < "\n\nm! = " < < factorial(m); Input : Enter the value of M : 5 M = 5 M! = 120 Ex:B3 Number to Words Aim : To write a C++ Program that displays the given number into words #include <iostream.h> int n; cout < < "\nenter the value of N : "; cin >> n ; cout < < "\n\nn = " < < n < < "\t" ; switch(n) case 1 : cout < < "One"; break; case 2 : cout < < "Two"; break; case 3 : cout < < "Three"; break; case 4 : cout < < "Four"; break; case 5 : cout < < "Five"; break; default: cout < < "Enter a number between 1-5";

Input : Enter the value of N : 5 N = 5 Five Ex:B4 Palindrome Checking Aim : to Write a program that tests Palindrome word #include < string.h> #include <iostream.h> char str1[100], str2[100]; cout << "\nenter a string : " ; cin.getline(str1, 100, '\n'); strcpy(str2, str1); strrev(str2); cout << "\ngiven String : " << str1; cout << "\nreversed String : " << str2; if(strcmp(str1, str2)==0) cout << "\npalindrome" ; else cout << "\nnot a Palindrome" ; Input : Ex:B5 Enter a string : madam Given String : madam Reversed String : madam Palindrome Odd/Even Number Checking Aim : To write a C++ program that counts odd/even numbers

int a[20], n, i, odd=0, even=0; cout < < "\nenter the Value of N : "; cin >> n; cout < < "\nenter array values : "; for(i=0; i< n; i++) cin >> a[i]; if(a[i]%2==0) even++; else odd++; cout < < "\ngiven Numbers are : "; for(i=0; i< n; i++) cout < < a[i] < < "\t"; cout < < "\nodd Numbers : " < < odd; cout < < "\neven Numbers : " < < even; Input : Enter the Value of N : 5 11 12 13 14 15 Given Numbers are : 11 12 13 14 15 Odd Numbers : 3 Even Numbers : 2 Ex:B6 Matrix Transpose Aim : To Transpose a given matrix int a[3][3], i, j;

cout < < "\nenter A(3X3) Matrix : "; cin >> a[i][j]; cout < < "\n\ngiven Matrix\n"; cout < < a[i][j] < < "\t"; cout < < "\n"; cout < < "\n\ntransposed Matrix\n"; cout < < a[j][i] < < "\t"; cout < < "\n"; Input : Enter A(3X3) Matrix : 1 2 3 4 5 6 7 8 9 Ex:B7 Given Matrix 1 2 3 4 5 6 7 8 9 Transposed Matrix 1 4 7 2 5 8 3 6 9 Matrix Addition Aim : to Add two 3 X 3 matrices

int a[3][3], b[3][3], c[3][3], i, j; cout < < "\nenter A(3X3) Matrix : "; cin >> a[i][j]; cout < < "\nenter B(3X3) Matrix : "; cin >> b[i][j]; c[i][j] = a[i][j] + b[i][j]; cout < < "\n\nmatrix A\n"; cout < < a[i][j] < < "\t"; cout < < "\n"; cout < < "\n\nmatrix B\n"; cout < < b[i][j] < < "\t"; cout < < "\n"; cout < < "\n\nmatrix C\n"; cout < < c[i][j] < < "\t"; cout < < "\n";

Input : Enter A(3X3) Matrix : 1 2 3 4 5 6 7 8 9 Enter B(3X3) Matrix : 9 8 7 6 5 4 3 2 1 Matrix A 1 2 3 4 5 6 7 8 9 Matrix B 9 8 7 6 5 4 3 2 1 Ex:B8 Matrix C 10 10 10 10 10 10 10 10 10 Prime Number Checking Aim : To write a C++ program that tests Prime number. int n, i; cout < < "\nenter a Number : "; cin >> n; for(i=2; i< n; i++) if(n%i==0)

cout < < n < < " is not a prime number"; return; cout < < n < < " is a prime number"; Input : Enter a Number : 7 Ex:B9 7 is a prime number Class Example Aim : To illustrate Class concept in C++ #include < stdio.h> class Employee int empno; char ename[35]; float basic, hra, da, netpay; float calculate(void) return basic+da+hra; public : void havedata(void) cout < < "\nenter employee number : "; cin >> empno; cout < < "\nenter employee name : "; gets(ename); cout < < "\nenter basic pay, hra, da : "; cin >> basic >> hra >> da;

netpay = calculate( ); void dispdata(void) cout < < "\nname : " < < ename; cout < < "\nemployee Number : " < < empno; cout < < "\nbasic Pay : " < < basic; cout < < "\nhra : " < < hra; cout < < "\nda : " < < da; cout < < "\nnet Pay : " < < netpay; ; Employee obj; obj.havedata( ); obj.dispdata( ); Input : Enter employee number : 12501 Enter employee name : Tamizh S Enter basic pay, hra, da : 12000 700 3000 Ex:B10 Name : Tamizh S Employee Number : 12501 Basic Pay : 12000 HRA : 700 DA : 3000 Net Pay : 15700 Function Overloading Aim : To write a C++ program for function overloading void max(int a, int b)

cout < < "\na = " < < a < < "\tb = " < < b; if(a>b) cout < < "\tmax = " < < a; else cout < < "\tmax = " < < b; void max(int a, int b, int c) cout < < "\na = " < < a < < "\tb = " < < b < < "\tc = " < < c; if(a>b) if(a>c) cout < < "\tmax = " < < a; else cout < < "\tmax = " < < c; else if(b>c) cout < < "\tmax = " < < b; else cout < < "\tmax = " < < c; max(10, 58); max(78, 125, -7); A = 10 B = 58 Max = 58 A = 78 B = 125 C = -7 Max = 125 Ex:B11 Inheritance Aim : To explain Inheritance concept in C++

class Add private: int sum ; protected: int num1, num2; public: Add( ) num1=num2=sum=0; void accept(void) cout < < "\nenter 2 numbers : "; cin >> num1 >> num2; void plus(void) sum=num1+num2; cout < < "\n\naddition"; cout < < "\nnum1 = " < < num1; cout < < "\nnum2 = " < < num2; cout < < "\nsum = " < < sum; ; class Subtract : public Add private : int sub; public : Subtract( ) num1=num2=sub=0; void minus(void) sub=num1-num2; cout < < "\n\nsubtraction"; cout < < "\nnum1 = " < < num1; cout < < "\nnum2 = " < < num2;

; cout < < "\nsub = " < < sub; Subtract obj; obj.accept( ); obj.plus( ); obj.minus( ); Input : Enter 2 numbers : 10 5 Ex:B12 Addition num1 = 10 num2 = 5 Sum = 15 Subtraction num1 = 10 num2 = 5 Sub = 5 Pattern Display Aim : To display the given pattern char str[10] = "COMPUTER"; int i; for(i=1; i< =8; i++) cout.write(str, i); cout < < "\n";

C CO COM COMP COMPU COMPUT COMPUTE COMPUTER