Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Converts theses codes from language c++ to c ( ex: from cin to scanf , cout to printf) (1) #include using namespace std; int main()
Converts theses codes from language c++ to c ( ex: from cin to scanf , cout to printf)
(1)
#include
using namespace std;
int main()
{
int arr[5];
int sum=0;
cout<<"Enter array elements (integer)"<
for (int i=0;i<5;i++)
cin>>arr[i];
for (int i=0;i<5;i++)
sum=sum+arr[i];
int avg=sum/5;
cout<<"Average is "<
}
(2)
#include
using namespace std;
int main()
{
int arr[8];
int even=0,odd=0;
cout<<"Enter 8 integer in array:"<
for (int i=0;i<8;i++)
cin>>arr[i];
for (int i=0;i<8;i++)
if(arr[i]%2==0)
even++;
else
odd++;
cout<<"Number of Even values in array are:"<
cout<<"Number of Odd values in array are:"<
}
(3)
#include
using namespace std;
int main()
{
cout<<"Enter how many elements do you want?"<
int n;
cin>>n;
int arr[n];
cout<<"Enter array element (integer):"<
for (int i=0;i
cin>>arr[i];
int min=arr[0];
for (int i=0;i<=n-1;i++)
{
if(arr[i]<=min&& i!=n-1)
{
min=arr[i];
}
else if(arr[i]<=min && i==n-1)
{
min=arr[i];
}
}
cout<
}
(4)
#include
using namespace std;
int main()
{
int arr[5];
cout<<"Enter 5 integer in array:"<
for (int i=0;i<5;i++)
cin>>arr[i];
cout<<"Reverse array is: "<
for (int i=4;i>=0;i--)
cout<
}
(5)
#include
using namespace std;
int main()
{
int arr[10];
cout<<"Enter 10 integer in array:"<
for (int i=0;i<10;i++)
cin>>arr[i];
cout<<"Enter search key: ";
int key;
cin>>key;
for (int i=0;i<10;i++)
if(arr[i]==key)
cout<<"The key is found at : "<
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started