Monday, June 18, 2012

To print a border line and sum of two integers using functions


/* Program that prints a border line and prints the sum of two integers using a function */

#include<stdio.h>

#include<conio.h>

/* Function Declaration */

void display();

void sum(int x,int y);

void main()

{

  int a,b;

  clrscr();

  printf("\nEnter two numbers:\n");

  scanf("%d%d",&a,&b);

  display();    /* Function Call*/

  sum(a,b);        /* Function Call*/

  display();    /* Function Call*/

  getch();

}

 

/* Function Definition */

void display()

{

  int i;

  printf("\n");

  for(i=1;i<=34;i++)

    printf("*");

}

/* Function Definition */

void sum(int x,int y)

{

  int temp;

  temp=x+y;

  printf("\n%d",temp);

}

 

OUTPUT

 

Enter two numbers:

23

35

 

**********************************

58

**********************************

 

 
 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.