Answers for "functions in c programming"

C
8

function in c

#include <stdio.h>

void function(){
  printf("I am a function!");
}

int main(void) {
  
  function();
}
Posted by: Guest on March-30-2020
3

functions in c programming

#include <stdio.h>
int addition(int num1, int num2)
{
     int sum;
     /* Arguments are used here*/
     sum = num1+num2;

     /* Function return type is integer so we are returning
      * an integer value, the sum of the passed numbers.
      */
     return sum;
}

int main()
{
     int var1, var2;
     printf("Enter number 1: ");
     scanf("%d",&var1);
     printf("Enter number 2: ");
     scanf("%d",&var2);

     /* Calling the function here, the function return type
      * is integer so we need an integer variable to hold the
      * returned value of this function.
      */
     int res = addition(var1, var2);
     printf ("Output: %d", res);

     return 0;
}
Posted by: Guest on December-15-2020
4

how to write function in c

#include <stdio.h>

// Here is a function declaraction
// It is declared as "int", meaning it returns an integer
/*
	Here are the return types you can use:
    	char,
        double,
        float,
        int,
        void(meaning there is no return type)
*/
int MyAge() {
	return 25;
}

// MAIN FUNCTION
int main(void) {
	// CALLING THE FUNCTION WE MADE
    MyAge();
}
Posted by: Guest on April-11-2020
0

functions in c programming

#include <stdio.h>
/* function return type is void and it doesn't have parameters*/
void introduction()
{
    printf("Hi\n");
    printf("My name is Chaitanya\n");
    printf("How are you?");
    /* There is no return statement inside this function, since its
     * return type is void
     */
}

int main()
{
     /*calling function*/
     introduction();
     return 0;
}
Posted by: Guest on December-15-2020

Code answers related to "C"

Browse Popular Code Answers by Language