0% found this document useful (0 votes)
6 views2 pages

Functions With Arguments in c

The document provides a complete guide on functions with arguments in C programming, explaining their purpose and types. It covers four types of functions: those with no arguments and no return value, those with arguments but no return value, those with no arguments but a return value, and those with both arguments and a return value. Each type is illustrated with code examples to demonstrate their use.

Uploaded by

nagas2820
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Functions With Arguments in c

The document provides a complete guide on functions with arguments in C programming, explaining their purpose and types. It covers four types of functions: those with no arguments and no return value, those with arguments but no return value, those with no arguments but a return value, and those with both arguments and a return value. Each type is illustrated with code examples to demonstrate their use.

Uploaded by

nagas2820
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Functions with Arguments in C Programming - Complete Guide with Example

1. Introduction to Functions with Arguments

Functions with arguments accept inputs and may return outputs. Arguments allow passing values to functions.

2. Types of Functions with Examples

2.1 No Arguments, No Return Value

These functions neither take inputs nor return any values.

#include <stdio.h>

void greet() {
printf("Hello, Sandeep!\n");
}

int main() {
greet(); // Function call
return 0;
}

2.2 Arguments but No Return Value

These functions take inputs but do not return any value.

#include <stdio.h>

void displaySum(int a, int b) {


printf("Sum: %d\n", a + b);
}

int main() {
displaySum(5, 3);
return 0;
}

2.3 No Arguments but Return Value

These functions return a value but do not take any input.

#include <stdio.h>

int getNumber() {
return 42;
}

int main() {
int num = getNumber();
printf("Number: %d\n", num);
return 0;
}

2.4 Arguments and Return Value

These functions take inputs and return a value.

#include <stdio.h>

int multiply(int a, int b) {


return a * b;
}

int main() {
int result = multiply(7, 6);
printf("Product: %d\n", result);
return 0;
}

3. Summary

- Functions help in code modularity and reuse.

- Types include:

1. No Arguments, No Return Value

2. Arguments but No Return Value

3. No Arguments but Return Value

4. Arguments and Return Value

You might also like