0% found this document useful (0 votes)
49 views2 pages

Arif Helmi B. Ahmad 2013869842 EC 110 /2 C1

This document contains code for a C++ program that swaps two integer values. It defines functions to get input, swap the numbers, and output the results. The main function calls the other functions to get input, swap the numbers, and display the swapped output.

Uploaded by

Sleepy Drone
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views2 pages

Arif Helmi B. Ahmad 2013869842 EC 110 /2 C1

This document contains code for a C++ program that swaps two integer values. It defines functions to get input, swap the numbers, and output the results. The main function calls the other functions to get input, swap the numbers, and display the swapped output.

Uploaded by

Sleepy Drone
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Arif Helmi b.

Ahmad
2013869842
EC 110 /2 C1

Exercise Chapter 5
Q1 d) $
$
$
$
522
555

Q4

#include <iostream.h>

void swap_number(int& val1, int& val2)


{

//function prototype

int input1, input2;

void get_input(int& input1, int& input2);

get_input(input1, input2);

void swap_number(int& val1, int& val2);


void result(int output1, int output2);

input2=val1;
input1=val2;

//main program

void main()
{

void result(int output1, int output2)


int input1, input2;

int val1, val2;

int val1, val2;

int output1, output2;

swap_number(val1, val2);

//get_input(input1, input2);

val1 =output1;

//swap_number(val1, val2);

val2 =output2;

result(output1, output2);
}

cout<<"\nNumber 2 is
"<<output2<<endl;
cout<<"Number 1 is
"<<output1<<"\n"<<endl;

void get_input(int& input1, int& input2)


{
cout<<"Enter number 1 : ";
cin>>input1;

cout<<"Enter number 2 : ";


cin>>input2;
}

You might also like