Search This Blog

Thursday, October 13, 2011

Write a program to generate a random int num and assign the same to a variable x through pointer. Display the value of x

   1:  #include<stdio.h>
   2:  #include<conio.h>
   3:  #include<stdlib.h>
   4:  void main()
   5:  {
   6:  int x,i;
   7:  int *xptr=&x;
   8:  srand(12345);
   9:  *xptr=rand();
  10:  printf("x=%d\n",x);
  11:  getch();
  12:  }

No comments:

Post a Comment