No arguments and No return values function:
#include<stdio.h> void sayHi(void); int main(void) { sayHi(); return 0 ; } void sayHi(void){ printf(“Hi to all \n”); } |
With arguments and No return values function: (Even Number Program)
#include<stdio.h> void isEven(int); int main(void) { int n; printf(“Enter number : “); scanf(“%d”, &n); isEven(n); return 0 ; } void isEven(int num){ if(num%2==0) printf(“%d is Even \n”, num); else printf(“%d is not Even \n”, num); } |
With arguments and No return values (Print ASCII value of given character):
#include<stdio.h> void ascii_value(char); int main(void) { char sym ; printf(“Enter symbol : “); scanf(“%c”, &sym); asciiValue(sym); return 0; } void asciiValue(char sym) { printf(“ASCII value is : %d \n”, sym); } |
With arguments and With return values function: (addition of 2 numbers)
#include <stdio.h> int add(int, int); int main() { int a, b, res; printf(“Enter two numbers : \n”); scanf(“%d%d”, &a, &b); res = add(a,b); printf(“%d + %d = %d\n”, a, b, res); return 0; } int add(int x, int y) { int z=x+y ; return z; } |
No arguments and With return values function:
float getPI(void); void main(void) { float pi; fpi = getPI(); printf(“PI value is : %f\n”, pi); } float getPI(void) { return 3.142; } |