Sum of two Integer numbers using function

In this C program we will calculate the summation of two numbers(int) using "Function" and print the result, in the screen. The two numbers will be taken from the user.color>

input:

Two numbers(int). (i.e. 15,23 etc.)

output:

Summation of the given numbers(int) will be printed on the screen.

CODE---->

` #include#include#includecolor>int sum();     /* function declaration */color>main()     /* main function */color>{      int choice;      printf("**********WELCOME**********\n\ncolor>");      printf("Please, select your choice.\ncolor>");      printf("1.Addition(press 1, for addition)\n2.Exit(press 2,for quit)\n\ncolor>");      printf("Please, Enter your choice : color>");      scanf("%dcolor>",&choice);      if(choice==1)      sum();     /* function call */color>      if(choice==2)      exit(0);      getch();}       /* end of main() function */      /* function structure */color>sum(){      int num1,num2,result;      printf("\nYou have selected addition option.\nPlease, Enter the 1st number : color>");      scanf("%dcolor>",&num1);      printf("\nPlease, Enter the second number : color>");      scanf("%dcolor>",&num2);      result=num1+num2;      printf("\nThe result is : %d + %d = %dcolor>",num1,num2,result);}`

Don't just read, write it, run it.....color>

RESULT:color>

This post first appeared on ProgramJoy.blogspot.com, please read the originial post: here

Share the post

Sum of two Integer numbers using function

×