1
Programming& ProblemSolving
/*Write a Program that takes input in an array of any size and reverses it.*/
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int arr[5];
for(int i=0;i<5;i++)
{
cout<<"entrnumber";
cin>>arr[i];
}
cout<<"inactual order.n";
for(i=0;i<5;i++)
cout<<arr[i]<<"n";
cout<<"inreverse order.n";
for(i=5;i>=0;i--)
cout<<arr[i]<<"n";
getch();
}
OUTPUT
/*Write a Program that displays the following series using recursion without loop.
2 4 6 8 10*/
2
Programming& ProblemSolving
#include<conio.h>
#include<iostream.h>
void f(int n)
{
cout<<n<<" ";
if(n<10) f(n+=2);
}
int main()
{
f(2);
getch();
}
OUTPUT
/*Write a program that input in an array of any size from the user stor them in an array and
display the sum and product of these values*/
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int arr[10],i,s=0,p=2;
for(i=0;i<10;i++)
{
cout<<"entr values = ";
cin>>arr[i];
s=s+arr[i];
}
p=p*s;
cout<<"sum is = "<<s<<"n";
cout<<"product is = "<<p<<"n";
getch();
}
OUTPUT

Assignement of programming & problem solving(3)a.z

  • 1.
    1 Programming& ProblemSolving /*Write aProgram that takes input in an array of any size and reverses it.*/ #include<iostream.h> #include<conio.h> void main() { clrscr(); int arr[5]; for(int i=0;i<5;i++) { cout<<"entrnumber"; cin>>arr[i]; } cout<<"inactual order.n"; for(i=0;i<5;i++) cout<<arr[i]<<"n"; cout<<"inreverse order.n"; for(i=5;i>=0;i--) cout<<arr[i]<<"n"; getch(); } OUTPUT /*Write a Program that displays the following series using recursion without loop. 2 4 6 8 10*/
  • 2.
    2 Programming& ProblemSolving #include<conio.h> #include<iostream.h> void f(intn) { cout<<n<<" "; if(n<10) f(n+=2); } int main() { f(2); getch(); } OUTPUT /*Write a program that input in an array of any size from the user stor them in an array and display the sum and product of these values*/ #include<iostream.h> #include<conio.h> void main() { clrscr(); int arr[10],i,s=0,p=2; for(i=0;i<10;i++) { cout<<"entr values = "; cin>>arr[i]; s=s+arr[i]; } p=p*s; cout<<"sum is = "<<s<<"n"; cout<<"product is = "<<p<<"n"; getch(); } OUTPUT