If you have some problem in C++ or either in C adding numbers by using a function and then I have some codes here that can really help you a lot.
Code:
#include<'stdio.h'>
#include<'conio.h'>
#include<'stdlib.h'>
#define p printf
int add(int x, int y)
{
int sum=0;
sum=x+y;
return sum;
}
int main()
{
menu:
system("cls");
int a,b;
p("Enter Num1: ");
scanf("%d", &a);
p("Enter Num2: ");
scanf("%d", &b);
p("\n\nThe sum of the two integers is %d.",add(a,b));
p("\n\n");
system("pause");
char choice;
p("\nDo you want to repeat the process?[y for yes][n for no]: ");
scanf("%s", &choice);
if(choice=='y'||choice=='Y')
goto menu;
else if(choice=='n'||choice=='N')
exit(0);
getch();
}
Post a Comment