Problem
Write a program in C language which takes two integers as input from user. Write a function to add these two integers and store the sum in another integer. Display the result.
Code
// lab02..cpp : Defines the entry point for the console application.//
#include "stdafx.h"
#include <iostream>
#include<conio.h>
using namespace std;
int sum (int, int);
int main()
{
int a,b,c;
cout << "Enter 1st number: ";
cin >> a;
cout<<"enter 2nd number: ";
cin >> b;
c = sum (a,b);
cout << "Sum = "<< c << endl;
cout<<"Press any key to close.";
getch();
return 0;
}
int sum (int a, int b)
{
int c;
c = a+b;
return c;
}
Output
Display Add/Sum of two integers in C Language |
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.