Â
In this, we are going to see Functions, the program is based on function which Calculates, Profit or Loss.
The code given below can be used for TURBO C++ Compiler:-
#include<iostream.h>
#include<conio.h>
//here we are declaring global variable
//named as lucky number of integer type
int lucky_number;
void user_input()
{
cout<<"Type your Lucky Number\n";
cin>>lucky_number;
}
void display_user_input()
{
cout<<"\nYour Lucky Number is: "<<lucky_number;
}
void main()
{
clrscr();
user_input();
display_user_input();
getch();
}
The code given below can be used for g++/gcc Compiler:-
#include<iostream>
using namespace std;
//here we are declaring global variable
//named as lucky number of integer type
int lucky_number;
void user_input()
{
cout<<"Type your Lucky Number\n";
cin>>lucky_number;
}
void display_user_input()
{
cout<<"\nYour Lucky Number is: "<<lucky_number;
}
int main()
{
user_input();
display_user_input();
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP