Friday, 3 June 2016

Program that accept two numbers and find power of first number up to second number.

Write a program that declares a function accepting two parameters. The first parameter is floating point number and second number is an integer. The program should multiply the floating point number by itself the number of times indicated by the integer. The function should return the result to the main function. The main function should ask the user for the floating point number and integer.It should...
Share:

Write a program that prompts the user for Cartesian coordinates of two points x1, y1, x2, y2 and displays the distance between them. Write a function distance() with input four parameters to compute the distance. The function returns distance to the calling function.

#include<iostream.h> #include<conio.h> #include<math.h> float Distance(int , int , int , int); void main() {       clrscr();       int cx1, cy1, cx2, cy2;       float result;       cout<<"Enter coordinates of  first point: ";       cin>>cx1>>cy1;       cout<<"Enter...
Share:

Write a program that inputs five numbers and passes the to a function one at a time.The function returns true if the integer is even and false otherwise.

#include<iostream.h> #include<conio.h> char check (int n); void main() {       clrscr();       int arr[5];       char r;       cout<<"Enter five numbers: "<<endl;       for(int i=0; i<5; i++)             cin>>arr[i];       for(i = 0; i<5; i++)  ...
Share:

Write a function that returns the smallest of three floating point numbers.

#include<iostream.h> #include<conio.h> float smallest (float a, float b , float c); void main() {       clrscr();       float n1, n2, n3;       cout<< "Enter three floating point numbers: ";       cin>>n1>>n2>>n3;       cout<<"The smallest floating number is: "<<smallest(n1,n2,n3);  ...
Share:

Write a program that calls two functions Draw_Horizontal and Draw_Vertical to construct a rectangle.

#include<iostream.h> #include<conio.h> void Draw_Horizontal(); void Draw_Vertical(); void main() {         clrscr();         cout<<"Rectangle : "<<endl;         Draw_Horizontal();         Draw_Vertical();         Draw_Horizontal();         getch(); } void...
Share:

Write a function LCM() that receives two integer arguments and return LCM

#include<iostream.h> #include<conio.h> int LCM(int n1, int n2); void main() {         int num1, num2, lcm;         do         {                 clrscr();                 cout<<"Enter two integers: ";            ...
Share:

Write a program that inputs a number in main() function and passes it to a function. The function displays whether number is prime or not.

#include<iostream.h> #include<conio.h> void prime(int n); void main() {         clrscr();         int num;         cout<<"Enter a number: ";         cin>> num;         prime(num);         getch(); } void prime(int n) {         int p =1;  ...
Share:

Write a program that prompts the user to enter a number and reverse it. Write a function Reverse() to reverse the number. The function should accept the number as the parameter and return the reverse number.

#include<iostream.h> #include<conio.h> int Reverse(int num); void main() {         clrscr();         int n, r;         cout<<"Enter a number: ";         cin>>n;         r = Reverse(n);         cout<<"The reverse number is : "<<r;    ...
Share:

Write a program that inputs two numbers in main function and passes them to a function. The function displays first number raised to the power of second.

#include<iostream.h> #include<conio.h> #include<math.h> void power(int n1, int n2); void main() {         clrscr();         int num1, num2;         cout<<"Enter two numbers: ";         cin>>num1>>num2;         power(num1, num2);         getch(); } void...
Share:

Wednesday, 1 June 2016

Write a Program that uses a function EQ() to find whether four integers a, b, c and d satisfy the equation a^3+b^3+c^3=d^3 or not. The function returns 0 if the equation is satisfied and return -1 otherwise.

#include<iostream.h> #include<conio.h> #include<math.h> int EQ(int a, int b, int c, int d); void main() {         clrscr();         int n1, n2, n3, n4, r;         cout<<"Enter four integers: ";        ...
Share:

Write a program that inputs two numbers in main function and passes them to a function. The function displays first number raised to the power of second.

#include<iostream.h> #include<conio.h> #include<math.h> void power(int n1, int n2); void main() {         clrscr();         int num1,  num2;         cout<<"Enter two numbers: ";         cin>>num1>>num2;  ...
Share:

Write a program that accept two integers.Create a function that tells whether or not the first integer is multiple of second.

#include<iostream.h> #include<conio.h> void check_multiple(int n1, int n2); void main() {        clrscr();        int int1, int2;        cout<<"Enter 1st integer: ";        cin>>int1;    ...
Share:

Write a program that enters and integer form the user and displays the Fibonacci numbers.

#include<iostream.h> #include<conio.h> void fibonacci(int n); void main() {        int num;        clrscr();        cout<<"Enter number upto which fibonacci numbers are required: ";        cin>>num;  ...
Share:

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

About Me

My photo
A group of two, with a little hope of helping beginners to learn how to code :)
Powered by Blogger.

Comments

Facebook

Ad Home

Follow Us

Random Posts

Sponsor

Recent Posts

Header Ads

Popular Posts

Copyright © 2025 Functions in C++ | Powered by Blogger

Design by ThemePacific | Blogger Theme by NewBloggerThemes.com | Distributed By Blogger Templates20