Tuesday, November 5
Functions in C++
(Post from Hamza Iqbal)
A program is a piece of code designed to solve a specific problem. In order to provide a solution to any problem a program must be divided into several tasks. Each task must then be further subdivided into a number of atomic(very basic tasks).
To emulate this behavior in programming we can use functions. Each function should ideally perform a single task, so when you are programming in c , c++ as a developer you must ensure this and if you feel that a function is performing multiple tasks then consider breaking down the function into several different functions.
How to define a function in C++
A program is a piece of code designed to solve a specific problem. In order to provide a solution to any problem a program must be divided into several tasks. Each task must then be further subdivided into a number of atomic(very basic tasks).
To emulate this behavior in programming we can use functions. Each function should ideally perform a single task, so when you are programming in c , c++ as a developer you must ensure this and if you feel that a function is performing multiple tasks then consider breaking down the function into several different functions.
How to define a function in C++
//Program explains use of functions int sum(int firstNum, int secondNum) /** * This is a sum function *It takes a two numbers(parameters) as input *it returns the sum of those numbers *This return value is given back to calling function **/ { return (firstNum + secondNum); } void sayHello() /** *This function sayHello, prints Hello to console *This does not take input nor returns any value **/ { cout<<"Hello"<
more posts please :)
ReplyDeletedo give a read to this most important post here on function pointers till now. c++ function pointers are explained there pretty well
ReplyDeleteO Thankyou Sir ,,, I hope this is Start ,,, INSHALLAH Next will be more than this ,,,,
ReplyDeletewhy have you not told about inline functions
ReplyDelete