SlideShare une entreprise Scribd logo
1  sur  12
1. What is computer?
ANS: A computer is a device that can be instructed to carry out sequences of
arithmetic or logical operations automatically via computer programming.
2. What is computer program?
ANS: A computer program is a set of instructions for a computer to follow
3. What is Computer software?
ANS: Computer software is the collection of programs used by a computer
4. Discuss Computer Vs Human?
ANS: Computers understand a language variously known as computer language or machine language.
 Therefore, computers and humans have agreed to sort of meet in the middle, using intermediate
languages
• Humans can speak C++ (sort of), and C++ is converted into machine language for the computer to
understand
5. What is Compilers?
ANS: Translate high-level language to machine language
6. What is source code?
ANS: Sourcecode: the original program in a high level language
7. What is object code?
ANS: the translated version in machine language
• Object code is also referred to as binary code or machine code
8. What is Linker?
• ANS: A Linker combines
• The object code for the programs we write
and
• The object code for the pre-compiled routines
into
The machine language program the CPU can run.
9. Why Do We Need Object-Oriented Programming?
ANS: Object-oriented programming was developed because limitations were discovered in earlier approaches
to programming. To appreciate what OOP does, we need to understand what these limitations are and how
they arose from traditional programming languages.
10. What is procedural language?
ANS: C, Pascal, and similar languages are procedural languages. That is, each statement in the language tells the
computer to do something.
11. What is class?
ANS: A class is a description of a number of similar objects.
12. What is instance of class?
Chapter 1: Object Oriented Programming in C++
ANS: specific people with specific names are members of this class if they possess certain characteristics. An
object is often called an “instance” of a class.
13. What are oo p characteristics?
14. What are the benefits of oop?
ANS:
15. What is Algorithm?
 ANS: Algorithms
◦ A sequence of precise instructions which leads to a solution
 Program
◦ An algorithm expressed in a language the computer can understand
16. How many types the problem solving in c++?
ANS: Problem Solving Phase
Implementation Phase
17. What is Problem solving Phase?
Develop the algorithm before implementation
18. What is implementation Phase?
ANS: Translate the algorithm into a programming
language
19. What are the three errors of programming language?
 Syntaxerrors
 Run-time errors
 Logicerrors
END Chapter1
20. What is Function?
 ANS: Functions are one of the fundamental building blocks of C++. The FIRST program consists almost
entirely of a single function called main ( ).
21. What is comment?
ANS: Comments help the person writing a program, and anyone else who must read the source file,
understand what’s going on.
22. Two types of comment?
 ANS: Single-line comment which begins with // and terminates at the end of the current line.
 Multi-line comment which begins with /* and ends with */.
23. What is Variable?
 ANS: A variable is a location in the computer's memory where a value can be stored for use by a
program.
 All variables must be declared with a name and a data type before they can be used in a program
 Declarations of variables can be placed almost anywhere in a program
 That value is actually placed in the memory space assigned to the variable.
Chapter2 C++Programming Basics
24. Tell the Basic Data base
25. Tell Their Basic Range
26. What is difference B/wee Expressions and Statements?
ANS: Any arrangement of variables, constants, and operators that specifies a computation is called an
expression.
Statements tell the compiler to do something and terminate with a semicolon.
27 Tell the rules of operator precedence?
ANS: PEDMAS (Parentheses, Exponents, Division, Multiplication, Addition and Subtraction)
END Chapter2
Q1: what is called operator that compares two values?
A1: A relational operator.
Q2: what do loops cause?
A2: Loops cause section of your program to be repeated a certain number of times.
Q3: what are three kinds of loops in C++?
• A3:There are three kinds of loops in C++:
• the for loop
• the while loop
• and the do loop
Q4: what is for loop?
A4: The for loop executes a section of code a fixed number of times.
Q5: when for loop used?
A5:It’s usually used when you know, before entering the loop, how many times you want to execute the code.
Q6: when while loop used?
A6: The while loop is used when you do not know how many times you want to do something before you start
the loop.
Q7: when test of while loop is evaluated?
A7: The test expression is evaluated at the beginning of the loop.
Q8: which have higher precedence arithmetic and rational operators?
A8: Note that arithmetic operators have a higher precedence than relational operators
Example (a < b / 2)
Q8: when do loop used?
A8: Use do loop when you want to guarantee that the loop body is executed at least once.
Chapter3 C++Programming Loops
Q9: when test of do while is evaluated?
A9: The test expression is evaluated at the end of the loop.
Q10: what do break and continue statement are used?
A10: break and continue statements are used to alter the flow of loops.
Q11: what are three types of decisions?
A11:
 The if statement
 The if...else statement
 Nested if...else statement
 The switch statement
Q12: what does if statement performs?
A12: The if statement performs an action if a condition is true or skips the action if the condition is false.
END Chapter3
Q1. Define function? And tell the most important reason to use functions?
A1. A function groups a number of program statements into a unit and gives it a name.
The most important reason to use functions is to:
Chapter4 C++ Programming Function
• Divide a program into units (divide & conquer).
• Reduce program size: the function’s code is stored in only one place in memory,
even though the function is executed many times.
Q2.What is the three components necessary to add a function to a program?
A2.The three components necessary to add a function to a program are:
a. the function declaration
b. the calls to the function
c. And the function definition.
Q3.Distinguish the different b/w function declaration, calling and function Definition?
A3. Function Declaration
 Declare the function before it is called
 Notice that the function declaration is terminated with a semicolon.
 Function declarations are also called prototypes, since they provide a model or
blueprint for the function.
 The keyword void specifies that the function has no return value, and the empty
parentheses indicate that it takes no arguments
Function calling
• To call a function we need: the function name, followed by parentheses.
• The syntax of the call is very similar to that of the declaration, except that the
return type is not used.
• The call is terminated by a semicolon.
Function definition
• The definition contains the actual code for the function.
• The definition consists of a line called the declarator, followed by the function
body.
• The declarator must agree with the declaration: It must use the same function
name, have the same argument types in the same order (if there are arguments),
and have the same return type.
• Notice that the declarator is not terminated by a semicolon.
Q4.Define declaration and tell some library functions?
A4.The declaration is in the header file specified at the beginning of the program (conio.h
for getche () and cmath.h for sqrt()).
Some library function such as getche () or sqrt ()?
Q5.What is an argument and parameters?
• An argument is a piece of data passed from a program to the function.
• Arguments allow a function to operate with different values, or even to do
different things, depending on the requirements of the program calling it.
The variables used within the function to hold the argument values are called
parameters.
Q6. What is the different b/w passing by value and passing by reference?
A6.Passing by value
• Passing by value means that the function creates copies of the arguments passed
to it. The called function creates a new variable of the same type as the argument
and copies the argument’s value into it.
• The function cannot access the original variable in the calling program, only the
copy it created.
• Passing arguments by value is useful when the function does not need to modify
the original variable in the calling program.
• In fact, it offers insurance that the function cannot harm the original variable.
Passing by reference
• In passing arguments by reference, a reference to the original variable, in the
calling program, is passed. (It is actually the memory address of the variable that
is passed).
• An important advantage of passing by reference is that:
 The function can access the actual variables in the calling program.
 It provides a mechanism for passing more than one value from the function
back to the calling program.
Q7.Describe Overloaded Functions with example?
A7.An overloaded function performs different activities depending on the kind of data
sent to it. It is more convenient to use functions with the same name even though they
each have different arguments.
Examples
• Declaration:
Voiddrawchar ();
Voiddrawchar (char);
Voiddrawchar (char, int);
• Calling:
Draw char ();
Draw char ('=');
Draw char ('+', 30);
Q8.What is Recursion?
A8.Recursion involves a function calling itself. Recursion is much easier to understand
with an example than with lengthy explanations.
Q9. What is Default Arguments?
A9.A function can be called without specifying all its arguments.
• The default argument follows an equal sign, which is placed directly after the type
name.
• Remember that missing arguments must be the trailing arguments—those at the
end of the argument list.
Q10. Differentiate Scope and Storage Class?
A10.scope
• The scope of a variable determines which parts of the program can access it, and
its storage class determines how long it stays in existence.
• Two different kinds of scope are important here: local and file.
 Variables with local scope are visible only within a block.
 Variables with file scope are visible throughout a file.
Storage Class
• A block is basically the code between an opening brace and a closing brace. Thus
a function body is a block.
• There are two storage classes: automatic and static.
• Variables with storage class automatic exist during the lifetime of the function in
which they are defined.
• Variables with storage class static exist for the lifetime of the program.
END Chapter4
C++ question and answers
C++ question and answers

Contenu connexe

Tendances

Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
Damian T. Gordon
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
Vasavi College of Engg
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
salmankhan570
 

Tendances (20)

Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to Coding
 
C language ppt
C language pptC language ppt
C language ppt
 
Spiral model presentation
Spiral model presentationSpiral model presentation
Spiral model presentation
 
Intro to software development
Intro to software developmentIntro to software development
Intro to software development
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
 
Java
JavaJava
Java
 
Paradigms
ParadigmsParadigms
Paradigms
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
Software development process models
Software development process modelsSoftware development process models
Software development process models
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
 
Loops in c
Loops in cLoops in c
Loops in c
 
Introduction to programming with c,
Introduction to programming with c,Introduction to programming with c,
Introduction to programming with c,
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
 
Loops c++
Loops c++Loops c++
Loops c++
 

Similaire à C++ question and answers

Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
miki304759
 
Top 40 C Programming Interview Questions
Top 40 C Programming Interview QuestionsTop 40 C Programming Interview Questions
Top 40 C Programming Interview Questions
Simplilearn
 

Similaire à C++ question and answers (20)

Pc module1
Pc module1Pc module1
Pc module1
 
C Language Presentation.pptx
C Language Presentation.pptxC Language Presentation.pptx
C Language Presentation.pptx
 
C programming
C programmingC programming
C programming
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Bcsl 031 solve assignment
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 
Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slides
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
cbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptxcbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptx
 
cbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptxcbybalaguruswami-e-180803051831.pptx
cbybalaguruswami-e-180803051831.pptx
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
 
Tutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng verTutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng ver
 
Technical trainning.pptx
Technical trainning.pptxTechnical trainning.pptx
Technical trainning.pptx
 
Top 40 C Programming Interview Questions
Top 40 C Programming Interview QuestionsTop 40 C Programming Interview Questions
Top 40 C Programming Interview Questions
 
Book management system
Book management systemBook management system
Book management system
 
C.pdf
C.pdfC.pdf
C.pdf
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

C++ question and answers

  • 1. 1. What is computer? ANS: A computer is a device that can be instructed to carry out sequences of arithmetic or logical operations automatically via computer programming. 2. What is computer program? ANS: A computer program is a set of instructions for a computer to follow 3. What is Computer software? ANS: Computer software is the collection of programs used by a computer 4. Discuss Computer Vs Human? ANS: Computers understand a language variously known as computer language or machine language.  Therefore, computers and humans have agreed to sort of meet in the middle, using intermediate languages • Humans can speak C++ (sort of), and C++ is converted into machine language for the computer to understand 5. What is Compilers? ANS: Translate high-level language to machine language 6. What is source code? ANS: Sourcecode: the original program in a high level language 7. What is object code? ANS: the translated version in machine language • Object code is also referred to as binary code or machine code 8. What is Linker? • ANS: A Linker combines • The object code for the programs we write and • The object code for the pre-compiled routines into The machine language program the CPU can run. 9. Why Do We Need Object-Oriented Programming? ANS: Object-oriented programming was developed because limitations were discovered in earlier approaches to programming. To appreciate what OOP does, we need to understand what these limitations are and how they arose from traditional programming languages. 10. What is procedural language? ANS: C, Pascal, and similar languages are procedural languages. That is, each statement in the language tells the computer to do something. 11. What is class? ANS: A class is a description of a number of similar objects. 12. What is instance of class? Chapter 1: Object Oriented Programming in C++
  • 2. ANS: specific people with specific names are members of this class if they possess certain characteristics. An object is often called an “instance” of a class. 13. What are oo p characteristics? 14. What are the benefits of oop? ANS: 15. What is Algorithm?  ANS: Algorithms ◦ A sequence of precise instructions which leads to a solution  Program ◦ An algorithm expressed in a language the computer can understand 16. How many types the problem solving in c++? ANS: Problem Solving Phase Implementation Phase 17. What is Problem solving Phase? Develop the algorithm before implementation 18. What is implementation Phase? ANS: Translate the algorithm into a programming language 19. What are the three errors of programming language?
  • 3.  Syntaxerrors  Run-time errors  Logicerrors END Chapter1 20. What is Function?  ANS: Functions are one of the fundamental building blocks of C++. The FIRST program consists almost entirely of a single function called main ( ). 21. What is comment? ANS: Comments help the person writing a program, and anyone else who must read the source file, understand what’s going on. 22. Two types of comment?  ANS: Single-line comment which begins with // and terminates at the end of the current line.  Multi-line comment which begins with /* and ends with */. 23. What is Variable?  ANS: A variable is a location in the computer's memory where a value can be stored for use by a program.  All variables must be declared with a name and a data type before they can be used in a program  Declarations of variables can be placed almost anywhere in a program  That value is actually placed in the memory space assigned to the variable. Chapter2 C++Programming Basics
  • 4. 24. Tell the Basic Data base 25. Tell Their Basic Range 26. What is difference B/wee Expressions and Statements? ANS: Any arrangement of variables, constants, and operators that specifies a computation is called an expression. Statements tell the compiler to do something and terminate with a semicolon. 27 Tell the rules of operator precedence? ANS: PEDMAS (Parentheses, Exponents, Division, Multiplication, Addition and Subtraction) END Chapter2
  • 5. Q1: what is called operator that compares two values? A1: A relational operator. Q2: what do loops cause? A2: Loops cause section of your program to be repeated a certain number of times. Q3: what are three kinds of loops in C++? • A3:There are three kinds of loops in C++: • the for loop • the while loop • and the do loop Q4: what is for loop? A4: The for loop executes a section of code a fixed number of times. Q5: when for loop used? A5:It’s usually used when you know, before entering the loop, how many times you want to execute the code. Q6: when while loop used? A6: The while loop is used when you do not know how many times you want to do something before you start the loop. Q7: when test of while loop is evaluated? A7: The test expression is evaluated at the beginning of the loop. Q8: which have higher precedence arithmetic and rational operators? A8: Note that arithmetic operators have a higher precedence than relational operators Example (a < b / 2) Q8: when do loop used? A8: Use do loop when you want to guarantee that the loop body is executed at least once. Chapter3 C++Programming Loops
  • 6. Q9: when test of do while is evaluated? A9: The test expression is evaluated at the end of the loop. Q10: what do break and continue statement are used? A10: break and continue statements are used to alter the flow of loops. Q11: what are three types of decisions? A11:  The if statement  The if...else statement  Nested if...else statement  The switch statement Q12: what does if statement performs? A12: The if statement performs an action if a condition is true or skips the action if the condition is false. END Chapter3 Q1. Define function? And tell the most important reason to use functions? A1. A function groups a number of program statements into a unit and gives it a name. The most important reason to use functions is to: Chapter4 C++ Programming Function
  • 7. • Divide a program into units (divide & conquer). • Reduce program size: the function’s code is stored in only one place in memory, even though the function is executed many times. Q2.What is the three components necessary to add a function to a program? A2.The three components necessary to add a function to a program are: a. the function declaration b. the calls to the function c. And the function definition. Q3.Distinguish the different b/w function declaration, calling and function Definition? A3. Function Declaration  Declare the function before it is called  Notice that the function declaration is terminated with a semicolon.  Function declarations are also called prototypes, since they provide a model or blueprint for the function.  The keyword void specifies that the function has no return value, and the empty parentheses indicate that it takes no arguments Function calling • To call a function we need: the function name, followed by parentheses. • The syntax of the call is very similar to that of the declaration, except that the return type is not used. • The call is terminated by a semicolon. Function definition • The definition contains the actual code for the function. • The definition consists of a line called the declarator, followed by the function body.
  • 8. • The declarator must agree with the declaration: It must use the same function name, have the same argument types in the same order (if there are arguments), and have the same return type. • Notice that the declarator is not terminated by a semicolon. Q4.Define declaration and tell some library functions? A4.The declaration is in the header file specified at the beginning of the program (conio.h for getche () and cmath.h for sqrt()). Some library function such as getche () or sqrt ()? Q5.What is an argument and parameters? • An argument is a piece of data passed from a program to the function. • Arguments allow a function to operate with different values, or even to do different things, depending on the requirements of the program calling it. The variables used within the function to hold the argument values are called parameters. Q6. What is the different b/w passing by value and passing by reference? A6.Passing by value • Passing by value means that the function creates copies of the arguments passed to it. The called function creates a new variable of the same type as the argument and copies the argument’s value into it. • The function cannot access the original variable in the calling program, only the copy it created. • Passing arguments by value is useful when the function does not need to modify the original variable in the calling program. • In fact, it offers insurance that the function cannot harm the original variable. Passing by reference
  • 9. • In passing arguments by reference, a reference to the original variable, in the calling program, is passed. (It is actually the memory address of the variable that is passed). • An important advantage of passing by reference is that:  The function can access the actual variables in the calling program.  It provides a mechanism for passing more than one value from the function back to the calling program. Q7.Describe Overloaded Functions with example? A7.An overloaded function performs different activities depending on the kind of data sent to it. It is more convenient to use functions with the same name even though they each have different arguments. Examples • Declaration: Voiddrawchar (); Voiddrawchar (char); Voiddrawchar (char, int); • Calling: Draw char (); Draw char ('='); Draw char ('+', 30); Q8.What is Recursion? A8.Recursion involves a function calling itself. Recursion is much easier to understand with an example than with lengthy explanations.
  • 10. Q9. What is Default Arguments? A9.A function can be called without specifying all its arguments. • The default argument follows an equal sign, which is placed directly after the type name. • Remember that missing arguments must be the trailing arguments—those at the end of the argument list. Q10. Differentiate Scope and Storage Class? A10.scope • The scope of a variable determines which parts of the program can access it, and its storage class determines how long it stays in existence. • Two different kinds of scope are important here: local and file.  Variables with local scope are visible only within a block.  Variables with file scope are visible throughout a file. Storage Class • A block is basically the code between an opening brace and a closing brace. Thus a function body is a block. • There are two storage classes: automatic and static. • Variables with storage class automatic exist during the lifetime of the function in which they are defined. • Variables with storage class static exist for the lifetime of the program. END Chapter4