I need these programs, in more than faster time, Answers should be in C++ tell m
ID: 3622752 • Letter: I
Question
I need these programs, in more than faster time,Answers should be in C++ tell me if you need more points, I just need the answers.
1.write a programme in c++ to input values in to an array.find out the total no of even and odd values entered in array
2.write a programme in c++ to input values into a table.find out total no of odd values in it
3.write a programme in c++ to input values into table,sort these values in asscending order and print them on screen in tabular form.
4.write a programme in c++ to input data into string .delete a specific character from string.print on screen the entered string and string after deleting specific character.
5.write a programme in c++ to input values into a table.find the maximum value entered in the table. print maximum value and its location.
6.write a programme in c++ to input data into string and find its length without any uesr defined function.
Explanation / Answer
please rate - thanks
you didn't mention anything about functions for numbers 1-5 so I didn't use any. If you need functions message me, I'll make the changes
1)
#include <iostream>
using namespace std;
int main()
{int a[50],odd=0,even=0,n=0,i;
cout<<"Enter numbers into an array <=0 to exit ";
cout<<"Enter element 1: ";
cin>>a[n];
while(a[n]>0)
{n++;
cout<<"Enter element "<<n+1<<": ";
cin>>a[n];
}
for(i=0;i<n;i++)
if(a[i]%2==0)
even++;
else
odd++;
cout<<"Number of odd elements: "<<odd<<endl;
cout<<"Number of even elements: "<<even<<endl;
system("pause");
return 0;
}
-------------------------------------------
2)
#include <iostream>
using namespace std;
int main()
{int a[50],odd=0,even=0,n=0,i;
cout<<"Enter numbers into an array <=0 to exit ";
cout<<"Enter element 1: ";
cin>>a[n];
while(a[n]>0)
{n++;
cout<<"Enter element "<<n+1<<": ";
cin>>a[n];
}
for(i=0;i<n;i++)
if(a[i]%2!=0)
odd++;
cout<<"Number of odd elements: "<<odd<<endl;
system("pause");
return 0;
}
--------------------------------------------------------
3)
#include <iostream>
using namespace std;
int main()
{int a[50],n,j,i,t;
cout<<"Enter numbers into an array <=0 to exit ";
cout<<"Enter element 1: ";
cin>>a[n];
while(a[n]>0)
{n++;
cout<<"Enter element "<<n+1<<": ";
cin>>a[n];
}
for(i=0;i<n-1;i++)
for(j=i;j<n;j++)
if(a[i]>a[j])
{t=a[i];
a[i]=a[j];
a[j]=t;
}
cout<<"Numbers sorted n number ";
for(i=0;i<n;i++)
cout<<i+1<<" "<<a[i]<<endl;
system("pause");
return 0;
}
------------------------------------------------
4)
#include <iostream>
using namespace std;
int main()
{string s,deleted="";
char c;
int i;
cout<<"Enter a string: ";
getline(cin,s);
cout<<"Enter character to delete: ";
cin>>c;
for(i=0;s[i]!='';i++)
if(s[i]!=c)
deleted=deleted+s[i];
cout<<"Original string: "<<s<<endl;
cout<<"With "<<c<<" deleted: "<<deleted<<endl;
system("pause");
return 0;
}
----------------------------------------------
5)
#include <iostream>
using namespace std;
int main()
{int a[50],n,i,max;
cout<<"Enter numbers into an array <=0 to exit ";
cout<<"Enter element 1: ";
cin>>a[n];
while(a[n]>0)
{n++;
cout<<"Enter element "<<n+1<<": ";
cin>>a[n];
}
max=0;
for(i=1;i<n;i++)
if(a[i]>a[max])
max=i;
cout<<"Largest value: "<<a[max]<<endl;
cout<<"Found at index: "<<max<<endl;
system("pause");
return 0;
}
------------------------
6)
#include <iostream>
using namespace std;
int main()
{string s;
cout<<"Enter a string: ";
getline(cin,s);
cout<<s<<" has "<<s.length()<<" characters ";
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.