The document contains 3 code snippets that solve different programming problems:
1) A program that reverses an array of any size by taking input from the user and displaying the array in reverse order.
2) A recursive program that displays the series 2 4 6 8 10 without using loops.
3) A program that takes input in an array from the user, calculates and displays the sum and product of the array values.
ICT Role in 21st Century Education & its Challenges.pptx
Assignement of programming & problem solving(3)a.z
1. 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. 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