Write a C program that has an integer array variable Userval
Solution
a)
#include <stdio.h>
#include<iostream>
int main()
{
int UserValue[500], *minimum, size, c, location = 1;
cout<<\"Enter the number of elements in array\"<<endl;
cin>>size;
cout<<\"Enter \"<<size<<\" integers\";
for ( c = 0 ; c < size ; c++ )
cin>>UserValue[c];
minimum = UserValue;
*minimum = *UserValue;
for ( c = 1 ; c < size ; c++ )
{
if ( *(UserValue+c) < *minimum )
{
*minimum = *(UserValue+c);
location = c+1;
}
}
cout<<\"Minimum element found at location \"<< location<<\" and it\'s value is \"<< *minimum<<end;
return 0;
}
b)
#include<conio.h>
#include<iostream>
void main()
{
char str[100];
char *p,*t;
cout<<\"Enter any string : \";
gets(str);
for(p=str ; *p!=NULL ; p++);
for(t=str, p-- ; p>=t; )
{
if(*p==*t)
{
p--;
t++;
}
else
break;
}
if(t>p)
cout<<\" String is Palindrome\";
else
cout<<\" String is not Palindrome\";
getch();
}
c)
#include<conio.h>
#include<iostream>
void main()
{
int size;
cin >> size;
double *num_array[] = new double[size];
double* a = num_array;
double total = 0;
for (int count =0; count< size; count++){
total = total + *(a + count);
}
cout << total/size;
}

