Thank you!!

but i already resolved the problem..
now may problem is the looping at the last part because when i use
switch statement the new value does not appear but when i use
if statement the new values print
Switch Statement Program
Code:
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define ARRAY_SIZE 4
int main(){
//Declare variable
int x=1,rep,i,temp=0;
char error[128];
// Declare array
int arr[]={2,3,4,5};
//Declare pointer
int *ptr;
do{
system("cls");
//Show value of variable
printf("Value of x: %d\n",x);
//Print address of variable
ptr=&x;
printf("Address of x: %p\n\n",ptr);
//Show value of array elements
printf("The value of elements inside the array:\n\n");
printf("Position\tElements\tAddresses\n\n");
for(i=0;i<ARRAY_SIZE;i++){
ptr=&arr[i];
printf("%d:\t\t%d\t\t%p\n",i,*ptr,ptr);
}
//Input address and new value
printf("\n");
printf("Please input an address: ");
scanf("%x",&ptr);
printf("address\n: %X",ptr);
printf("Please input the new value: ");
scanf("%d",&temp);
*ptr=temp;
printf("address: %d\n",temp);
printf("Please press the spacebar to continue!!");
getche();
while(rep>2||rep<1){
system("cls");
printf("Do you want to repeat the computation?\n\n");
printf("1 - Yes\n");
printf("2 - No\n");
scanf("%s",&error);
rep=atoi(error);
switch(rep){
case 1:
main();
break;
case 2:
return 0;
break;
default:
system("cls");
printf("Invalid input. Please try again!!!\n");
printf("Please press the spacebar to continue!!");
getche();
break;
}
}
}while(rep==1);
}
If Statement Program
Code:
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define ARRAY_SIZE 4
int main(){
//Declare variable
int x=1,rep,i,q,temp=0;
char error[128];
// Declare array
int arr[]={2,3,4,5};
//Declare pointer
int *ptr;
do{
system("cls");
//Show value of variable
printf("Value of x: %d\n",x);
//Print address of variable
ptr=&x;
printf("Address of x: %p\n\n",ptr);
//Show value of array elements
printf("The value of elements inside the array:\n\n");
printf("Position\tElements\tAddresses\n\n");
for(i=0;i<ARRAY_SIZE;i++){
ptr=&arr[i];
printf("%d:\t\t%d\t\t%p\n",i,*ptr,ptr);
}
//Input address and new value
printf("\n");
printf("Please input an address: ");
scanf("%x",&ptr);
printf("address: %X\n",ptr);
printf("Please input the new value: ");
scanf("%d",&temp);
*ptr=temp;
printf("address: %d\n",temp);
printf("Please press the spacebar to continue!!");
getche();
while(q!=1){
if(q==2){system("cls");
printf("Input must be either 1 or 2\n");}
printf("\n\nReturn to view new list or quit?\n");
printf("\n[1] Return\n[2] Quit\n");
scanf("%d",&rep);
if(rep==1)q=1;
if(rep==2)return 0;
if(rep!=1&&rep!=2)q=2;
}//while q!=1
q=0;
}while(rep==1);
}