Write a C program that has an integer array variable Userval

Write a C++ program that has an integer array variable Uservalues, which has a size of 500 elements. Then, declare a pointer that is used to scan the array UserValues to find the maximum value. Write a C++ program that checks if a word is palindrome or not. A palindrome word is one that reads the same backward or forward. For example the words \"civic\" and \"level\" are palindrome words, while \"hello\" and \"car\" aren\'t. First, prompt the user to enter a word and stores it in a character array. Then, use two pointers to scan the array (each pointer is at one end of the array) to determine if the word is palindrome or not. Use dynamic memory allocation to create a double array of size determined by the user at run time. Then, find the average of the array values. You are not allowed to access any array element except through the pointer. In other words, you can only access an array element by offsetting the pointer value (e.g. ptr + offset) and NOT through the traditional way (i.e. [element index]).

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;
}

 Write a C++ program that has an integer array variable Uservalues, which has a size of 500 elements. Then, declare a pointer that is used to scan the array Use
 Write a C++ program that has an integer array variable Uservalues, which has a size of 500 elements. Then, declare a pointer that is used to scan the array Use

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site