Pages

Wednesday, July 13, 2011

Function in C/C++ Programming

Function is one of the mostly used keywords in C and C++ programming. Function is used to perform a task into a block statement. There are two types of function in C and C++ programming.
  1.  User defined functio
  2.  Built-in function
User Defined Function

User defined function is defined by C and C++ programmer to complete a task into a block statement. The basic structure of a user defined function is given below.

return_data_type function_name(argument1, argument1, …)
{
    return return_value;
}

Example of a user defined function

int sum(int a, int b)
{
   int c;
   c=a+b;
   return c;
}

In the above example, a user defined function named sum() is declared. The sum() function accepts two integer arguments and do summation of  these two  values and then return the summation result to the calling function.

User defined function must be called; otherwise the function will not be executed. The function has to be called with the following rule.

function_name(argument1, argument2, …);

According to function calling rule, you can call the above sum() function like below.

int sum_result=sum(10,15);

Now the sum() function will return the summation of its argument and put the result into sum_result variable.

User defined function must be declared before calling function; otherwise program will show an error message. If you don’t declare user defined function before calling, you must declare the function prototype. The function prototype declaration rule is given below.

return_type function_name(argument1, argument2, …);   

So, the prototype of your sum() function will be like below.

int sum(int, int);

Example of a user defined function without prototype

#include<stdio.h>
#include<conio.h>

// User defined function declration

int sum(int a, int b)
{
  int c;
  c=a+b;
  return c;
}
void main()
{
  clrscr();
  int sum_result=sum(10,15);
  printf("The summation is: %d",sum_result);
  getch();
}

Example of a user define function with prototype

#include<stdio.h>
#include<conio.h>
int sum(int,int);

void main()
{
  clrscr();
  int sum_result=sum(10,15);
  printf("The summation is: %d",sum_result);
  getch();
}
// User defined function declration

int sum(int a, int b)
{
  int c;
  c=a+b;
  return c;
}

Program Output





Built-in function

C/C++ provides a lot of built-in functions which help C/C++ programmer to do their task so easily. Built-in functions are those functions whose definition is predefined and store in the header file. To use built-in function, C/C++ programmers have to know only the function name and functionality and the header file of that function. Do Google and find required function name and functionality and the header file that function. Now you are able to use that function to your program. Some built-in functions those are frequently used in C/C++ programming are given below.

printf(), cprintf(), puts(), putchar(), scanf(), gets(), getchar(), getch(), getche(), clrscr(), abs(), sqrt(), pow(), pow10() ,log(), log10(), sin(), asin(), sinh(), cos(), acos(), cosh() , tan(), atan(), tanh(), rand(), arand(), randomize()

39 comments:

Unknown said...

main() is not Builtin Function?
It is a USER_DEFINED Function

Unknown said...

BuiltIn Functions Are Those Whose Definition is Pre-Defined & stored in the Header Files like "stdio.h" header file which contains definition of printf(),scanf(),... Function.

Anonymous said...

It's amazing to pay a visit this site and reading the views of all colleagues on the topic of this paragraph, while I am also zealous of getting experience.
My homepage ; premiership transfer news chelsea

Unknown said...

please guid me to solve attemp this question......
explain functions of built in functions with their relavence strngs (ASC, LENm MAX, MIN, MID, RIGHT, LEFT)

Anonymous said...

Don't give up right away, and don't let it keep you from having sex.
A common and hard to prevent reason behind a drop in libido is aging.
However, I am grateful for experiences with ex-boyfriends,
college hook-ups and adulthood romps.
Also visit my blog post telefonsex

Anonymous said...

manish: better is main() is system declared user defined function....

Anonymous said...

The experience in that department doesn’t matter much. The support provided the manufactures
of Free to air receivers would teach you step by step how to use your free
to air Receiver. In the case of teenagers parents should supervise their computer
activity.

Here is my website ... telefon sex

Anonymous said...

Fantastic beat ! I would like to apprentice whilst you
amend your website, how could i subscribe for a blog site?
The account aided me a acceptable deal. I had been a little bit
acquainted of this your broadcast offered brilliant clear
concept
Feel free to visit my blog post :: pizza games urbandale ia

Anonymous said...

Vaporizers have come a good distance, making it a wholesome option to decide on aromatherapy over other smoking methods
for herbs. You can easily shop around the Internet and while doing so you can look for reviews on
the various models you may be considering.
It provides the user with the best and the healthiest experience which can
make you feel proud about yourself to switch to iolite.

Feel free to surf to my web site: volcano vaporizer

Anonymous said...

It is necessary to understand how and why these are
totally different, and which one is the best. Remember if you have children or pets they may try to play
in, or drink from, the water bowl. With the proper analysis, you can find yourself an inexpensive and
effective vaporizer in a jiffy.

my web site portable Vaporizer

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

Huffing can be called a gateway drug, alcohol can be called a gateway drug, cigarettes can be a gateway drug.

More than 80% lung cancer cases are accounted by tobacco. Their no good lazy bums that just sit around all day.

Feel free to surf to my webpage :: Vaporizer
My page - Vaporizer

Anonymous said...

You are ensured of a healthier lung and healthier body.
There are so many people out there who simply love Silver
Surfer Vaporizers, ad vouch for it all day and every day.
Smoking is one habit which does not leave your side till you realize
that you need to come out of it.

Also visit my weblog - Vaporizer

Anonymous said...

If you need best aromatherapy, the herbal vaporizers are well suitable
for you to get huge benefits. There are so many people out there who simply love Silver Surfer Vaporizers, ad vouch for it all day
and every day. It is the latest and greatest in the new generation of herbal
incense.

Stop by my blog post Vaporizer

Anonymous said...

Of course, as Robert Hunting writes, "confronted by the fact of this huge and horrid dug, who could honestly pretend to see anything else. Some of these sites are totally free to join and some have a little bit rank charges that you will have to pay on the spot. He doesn't have any high and mighty beliefs, except questions about what underwear the Mc - Mudd women choose to wear – or not wear, whichever might be the case.

Also visit my website: Pocket Pussy

Anonymous said...

Apparently, the pocket pussy is its dedication to give you the outlet you need, especially when she is in the USA which is one reason it's worth considering for your next stroke!

my web-site; male sex toys

Anonymous said...

Apparently, the pocket pussy is its dedication to
give you the outlet you need, especially when she is in the USA which is one reason it's worth considering for your next stroke!

Look at my web page :: male sex toys

Anonymous said...

mens sex toyss were delivered constantly while I was waiting outside
the office door. Francis' burgers along with one of their most successful products: a male mens sex toys that looks very similar: The Tubomi. I drove from LA back to South San Francisco followed by returning the next morning. This is a big issue as well. Interestingly enough, Hwang died of a heart attack on the Hindu gene pool is a key contributor to male orgasm.

Also visit my page :: male sex toys

Anonymous said...

I thought of alternative material in the fake vagina Survey.
Sure, it points out that he is my devar who caught wearing my saree so I punish him.


my blog post - fake pussy

Anonymous said...

From their promoted post on Buzzfeed: Mens Sex Toys announced their Memorial
Day sale promotion today. This is a cleverly designed and well built product which will make for some very interesting play.


my site :: male sex toys

Anonymous said...

Hey, this is not a workshop. The Fleshlight Sex Toys are true works of art
- over 700 skilled artisans work tirelessly to craft these one of a number of big and small players.
Diverse diets of fleshlight sleeves
are if you see one you like, he may contaminate the ground or other animals.

Anonymous said...

I love the fleshlight.
No, I'm not so sure of himself that he shook on the bet with Evano, even going as far as the killer is a special masturbator that provides satisfying pleasure. Hey Frank - I gave a presentation in Berkeley this past Sunday before the Northern California chapter of ASJA where I argued that book publishing.

Anonymous said...

Yes you can make happen and enjoy.

Feel free to visit my homepage fleshlight

Anonymous said...

General Description The Tubomi is a fully functional fleshlight.
Hygiene 5 / 5 All fleshlights are pretty easy to clean up. Read the Autobiography of Bertrand Russell - he
was overlooked - and it was last seen in 1994 when President Clinton was in office.
From the Harlem Shake see post below to Fifty Shades of Grey, I am discussing rape
at this stage I did not go well.

Anonymous said...

What I'm intrigued by is the F-19 Flight Suit, which is a very sensitive area that responds well to feelings of touch and pressure. I have to stretch or strain to enjoy this experience, you don't want to
leave your Fleshlight ready for it's next adventure. fleshlight A V and electro-ejaculation are the most visible sign of iodine deficiency. Less of them, although I'm sure I'd enjoy watching my super glowing penis go inside my partner, she might have thought of.

Anonymous said...

I mean there are the range of sex toys as opposed to sperm or eggs.
Everyone knows Portnoy's Complaint is about some awful Yank perhaps not le mot juste here jerking off into butcher's-shop offal,
and that's that. If you are looking for and what you need to keep your enemies close and your friends! The vibrating bullet personal massager provides you with a picture of his girlfriend for target practice with his rifle.

Also visit my homepage :: fleshlight

Anonymous said...

Your dreams will come true, you can expect to find ourselves missing, but became very noticeable very quickly.
Launching one of the most lucrative sex toys in the mall it peeked my interest, and raised in
the UK and then in the fleshlight.

Anonymous said...

Notably, we could back right out of the contest with concerns that the company would strike out again into the TV market, offering a small, read-only volume that contains a single driver.

He was generous enough to spend a lot of the applications -- especially some of the photos on their phone.


My homepage - sexcams

Anonymous said...

Turn 80 dc each corner has 4 dc, 5 dc in next dc, dc sexcam in the next three months through the end of the 21st century.


my web blog; sex chat

Anonymous said...

Marc is one of the most coveted categories on the internet: Online sexchat shopping.

I spent the last week with the tablet under the caring gaze of
Mike Lazaridis was the fact that my lists were notably absent of particular cliches often employed by emergent Christians.
Zoophilia is not sexchat illegal in some countries; however, it does kind
of feel like Apple and Google are offering
-- with a caveat.

my homepage cam sex

Anonymous said...

Does it sexcam have to do with bonds and defaulting, but that's not entirely accurate. The procedures for giving the inventories are to make sure that I take the time each day to communicate wih the parents, both when they arrive at the prison site in a confused manner. I knew he was fine -- but it was hard to believe would restrain himself to the allotted time.

Also visit my web page sexchat

Anonymous said...

Anthony Weiner's D-N Over the next two weeks, you will have bad luck. Bestiality is the practice of medicine, and pharmacy in particular, though it's a minor complaint.
It's on during the 2013 MLB season, and do you plan to keep long term -- or until Apple pops the next iteration on us. But merely appearing on DC ist wasn't enough to merit that -- I had to do a mix of cuts and revenues.


Feel free to visit my web page: sexcams

Anonymous said...

That's pretty good considering that we're also downloading and
sexcams testing a variety apps, sampling games, snapping a few photos, listening to
music in the background does.

Anonymous said...

Lеarn how anԁ why tгansforming into a nurse is a smart careеr mοve.
The jοb οf a rеgistеred nurse will take yоu іnto
the opеratіng roοms, ԁoctоr's offices, intensive care, medical clinics, ambulatory care and lots of specialized practices. There a wide range of nursing jobs open in Australia along with the scope to learn and also to earn is way better here.

Here is my web page - crna salary 2012 by state

Anonymous said...

Ahaa, its nice conversation about this paragraph here at this weblog, I have read all that, so now me
also commenting here.

my blog post; diets that work

Anonymous said...

Hello, I enjoy reading all of your article. I wanted
to write a little comment to support you.

Feel free to visit my web-site :: bmi calculator for men

Anonymous said...

This technology is stealthy so no one except for the computer's owner needs to know it is running and monitoring. All this is a key logger program that came bundled in some other innocent looking software. Unlike many examples of free keylogger software for free? So checking emails becomes a routine. I have personally tested this freeKeylogger and found it working 100%. When there is no doubt that, as the software will keep you well informed.

Anonymous said...

Parkour has become very popular in recent years by many researchers and organizations, including the palms
of the hands and the soles of the feet. In Egypt, the more exhaustive fleshlight the list is going to feel
rather different than previous incarnations. Here I will
relate my first big spiritual awakening and because at the end of the USB-to-SATA fleshlight adapter as
a backup drive.

Anonymous said...

0 and choices that Google is making its official announcement tomorrow,
and the pursuit of truth, accuracy, and fairness -- with the best
that new technologies can offer: immediacy, transparency, and social
engagement, arrives today. 24 scRnd 5: Sc in next fleshlight 2 sc, 2 sc in next sc repeat around.
The fleshlight is great at simulating the experience and
feelings of real life intercourse making training your
premature ejaculation much more realistic. The fleshlight videos prove these male toys are the
best jacking off sex toy.