Ya War 39785 Array PF
Ya War 39785 Array PF
ID NO:- 39785
ASSIGNMENT :- ARRAY
main() {
= arr[start]; arr[start] =
start++; end--;
}
cout<<"before reverse = "<<"1 2 3 4
}
return 0;
}
NAME:- YAWAR MUJTABA
ID NO:- 39785
ASSIGNMENT :- ARRAY
2. .write a c++ program to find the minimum value of an array.
Ans: #include
<iostream> using
main() {
int size;
cout << "Enter the size of the
}
int min = arr[0]; for
min = arr[i];
}
}
cout << "Minimum Value: " << min << endl;
return 0;
}
NAME:- YAWAR MUJTABA
ID NO:- 39785
ASSIGNMENT :- ARRAY
int x;
n; i++) { if(arr[i] == x) {
return 0;
}
NAME:- YAWAR MUJTABA
ID NO:- 39785
ASSIGNMENT :- ARRAY
4. Take 10 integers input from the user and store the in array . Again ask the
user to give a number now , tell the user whether that number is present in
array or not.
Ans:
#include<iostream>
int main() {
}
int num; cout << "Enter a
}
}
if(found)
{
NAME:- YAWAR MUJTABA
ID NO:- 39785
ASSIGNMENT :- ARRAY
cout << "Number is present in the array.";
} else {
cout << "Number is not present in the array.";
}
return 0;
}
5.write a c++ program to input elements in an array from user and count even
and odd in the array?
Ans:
#include<iostream> using
if(arr[i] % 2 == 0) {
even++;
NAME:- YAWAR MUJTABA
ID NO:- 39785
ASSIGNMENT :- ARRAY
}
Else
{
odd++;
}
}
endl; cout << "Number of odd numbers: " << odd <<
endl;
return 0;
}
";
}
cout << endl; cout << "Enter the position where you want
to insert an element: "; cin >> pos; cout << "Enter the value
// Shift elements to the right to make space for the new element
for(int i = 9; i >= pos; i--) {
}
arr[pos - 1] = val; cout <<
}
cout << endl;
return 0;
}
NAME:- YAWAR MUJTABA
ID NO:- 39785
ASSIGNMENT :- ARRAY