Answer
-
chat gay almeria https://gaytgpost.com/
Answered By:b gay chat -
international gay dating websites https://gaypridee.com/
Answered By:gay dating free -
gay jerk off chat https://bjsgaychatroom.info/
Answered By:gay kink chat -
3muslims
Answered By:2decisions -
Hydraruzxpnew4af — самая крупная торговая онлайн-площадка в сети, где каждый найдёт для себя нужный товар. Это официальный сайт Гидра от Администрации проекта, работающий на всей территории СНГ и не требующий TOR-соединения. Гидра вход и ссылка Гидра
Answered By:Lesliemal -
Hydraruzxpnew4af — самая крупная торговая онлайн-площадка в сети, где каждый найдёт для себя нужный товар. Это официальный сайт Гидра от Администрации проекта, работающий на всей территории СНГ и не требующий TOR-соединения. Гидра вход и ссылка Гидра
Answered By:Lesliemal -
Answered By:Luannurink
-
Всем привет, если вы ищете реальный сайт казино без
Answered By:Lesliemal -
Разряд «Ринтарп» активно работает на белорусском рынке строительного оборудования с 2000 года. Основное настроение деятельности компании — действие и продажа строительного оборудования. Подробнее о Ринтарп хомутовые леса У нас Вы можете умазывать: — строительные конструкции: леса рамные, хомутовые леса, клиновые леса; вышки-туры, строительные вышки-туры из алюминия; алюминиевые лестницы, строительный мусоропровод и др. — обстановка чтобы работы с бетоном: бетономешалки, растворосмесители, штукатурные станции, бетононасосы, торкрет установки, бадьи чтобы хранения бетона и др. — грузоподъемное снаряжение: тали, лебедки, домкраты, краны, подъемники, монтажные блоки и др. — вибротехнику: площадочные и глубинные вибраторы, наконечники и гибкие валы к ним, рейки, плиты, трамбовки и др. — сварочное снасти: полуавтоматы, трансформаторы, генераторы, выпрямители, инверторы и др. — тепловое: водонагреватели, котлы отопления, тепловые пушки, завесы, инфракрасные, масляные обогреватели, тепловентиляторы и др. —Складская техника: тележки, штабелеры, столы подъемные, сборщики заказов, ричтраки (штабелеры-погрузчики), тягачи, погрузчики. https://www.linkedin.com/company/rinstroy
Answered By:DarrenMor -
New programmers are usually in the search of ways to return multiple values from a function. Unfortunately, C and C++ do not allow this directly. But fortunately, with a little bit of clever programming, we can easily achieve this.
Below are the methods to return multiple values from a function in C:
- By using pointers.
- By using structures.
- By using Arrays.
Example: Consider an example where the task is to find the greater and smaller of two distinct numbers. We could write multiple functions. The main problem is the trouble of calling more than one functions since we need to return multiple values and of course having more number of lines of code to be typed.
- Returning multiple values Using pointers: Pass the argument with their address and make changes in their value using pointer. So that the values get changed into the original argument.
// Modified program using pointers
#include <stdio.h>
// add is the short name for address
void
compare(
int
a,
int
b,
int
* add_great,
int
* add_small)
{
if
(a > b) {
// a is stored in the address pointed
// by the pointer variable *add_great
*add_great = a;
*add_small = b;
}
else
{
*add_great = b;
*add_small = a;
}
}
// Driver code
int
main()
{
int
great, small, x, y;
printf
(
"Enter two numbers: \n"
);
scanf
(
"%d%d"
, &x, &y);
// The last two arguments are passed
// by giving addresses of memory locations
compare(x, y, &great, &small);
printf
(
"\nThe greater number is %d and the"
"smaller number is %d"
,
great, small);
return
0;
}
Output:Enter two numbers: 5 8 The greater number is 8 and the smaller number is 5
- Returning multiple values using structures : As the structure is a user-defined datatype. The idea is to define a structure with two integer variables and store the greater and smaller values into those variable, then use the values of that structure.
// Modified program using structures
#include <stdio.h>
struct
greaterSmaller {
int
greater, smaller;
};
typedef
struct
greaterSmaller Struct;
Struct findGreaterSmaller(
int
a,
int
b)
{
Struct s;
if
(a > b) {
s.greater = a;
s.smaller = b;
}
else
{
s.greater = b;
s.smaller = a;
}
return
s;
}
// Driver code
int
main()
{
int
x, y;
Struct result;
printf
(
"Enter two numbers: \n"
);
scanf
(
"%d%d"
, &x, &y);
// The last two arguments are passed
// by giving addresses of memory locations
result = findGreaterSmaller(x, y);
printf
(
"\nThe greater number is %d and the"
"smaller number is %d"
,
result.greater, result.smaller);
return
0;
}
Output:
Enter two numbers: 5 8 The greater number is 8 and the smaller number is 5
- Returning multiple values using an array (Works only when returned items are of same types): When an array is passed as an argument then its base address is passed to the function so whatever changes made to the copy of the array, it is changed in the original array.
Below is the program to return multiple values using array i.e. store greater value at arr[0] and smaller at arr[1].// Modified program using array
#include <stdio.h>
// Store the greater element at 0th index
void
findGreaterSmaller(
int
a,
int
b,
int
arr[])
{
// Store the greater element at
// 0th index of the array
if
(a > b) {
arr[0] = a;
arr[1] = b;
}
else
{
arr[0] = b;
arr[1] = a;
}
}
// Driver code
int
main()
{
int
x, y;
int
arr[2];
printf
(
"Enter two numbers: \n"
);
scanf
(
"%d%d"
, &x, &y);
findGreaterSmaller(x, y, arr);
printf
(
"\nThe greater number is %d and the"
"smaller number is %d"
,
arr[0], arr[1]);
return
0;
}
Output:Enter two numbers: 5 8 The greater number is 8 and the smaller number is 5
C++ Only Methods
- Returning multiple values Using References: We use references in C++ to store returned values.
// Modified program using References in C++
#include <stdio.h>
void
compare(
int
a,
int
b,
int
&add_great,
int
&add_small)
{
if
(a > b) {
add_great = a;
add_small = b;
}
else
{
add_great = b;
add_small = a;
}
}
// Driver code
int
main()
{
int
great, small, x, y;
printf
(
"Enter two numbers: \n"
);
scanf
(
"%d%d"
, &x, &y);
// The last two arguments are passed
// by giving addresses of memory locations
compare(x, y, great, small);
printf
(
"\nThe greater number is %d and the"
"smaller number is %d"
,
great, small);
return
0;
}
Output:Enter two numbers: 5 8 The greater number is 8 and the smaller number is 5
- Returning multiple values using Class and Object : The idea is similar to structures. We create a class with two integer variables and store the greater and smaller values into those variable, then use the values of that structure.
// Modified program using class
#include <stdio.h>
class
GreaterSmaller {
public
:
int
greater, smaller;
};
GreaterSmaller findGreaterSmaller(
int
a,
int
b)
{
GreaterSmaller s;
if
(a > b) {
s.greater = a;
s.smaller = b;
}
else
{
s.greater = b;
s.smaller = a;
}
return
s;
}
// Driver code
int
main()
{
int
x, y;
GreaterSmaller result;
printf
(
"Enter two numbers: \n"
);
scanf
(
"%d%d"
, &x, &y);
// The last two arguments are passed
// by giving addresses of memory locations
result = findGreaterSmaller(x, y);
printf
(
"\nThe greater number is %d and the"
"smaller number is %d"
,
result.greater, result.smaller);
return
0;
}
Output:Enter two numbers: 5 8 The greater number is 8 and the smaller number is 5
Answered By:arvin
Your Answer
2259
Questions