array and pointers uses in c that you should know in programming

Spread the love
5 important programs that you should know:

1.sorting technique of array using pointers:

#include<stdio.h>
#include<stdlib.h>
void create_array(int *p,int n);
void display(int *p,int n);
void sorting(int *p,int n);
int main()
{
    int *p,n;
    printf(“enter how many element you want to insert in the array?\n”);
    scanf(“%d”,&n);
    p=(int *)malloc(sizeof(int)*n);
    create_array(p,n);
     return 0;
}
void create_array(int *p,int n)
{
     printf(“enter the element in the array”);
    for(int i=0;i<n;i++)
    {
        scanf(“%d “,&p[i]);
    }
    display(p,n);
    sorting(p,n);
    printf(“after sorting\n”);
     display(p,n);

 

}
void display(int *p,int n)
{
     printf(“enter the element in the array”);
    for(int i=0;i<n;i++)
    {
        printf(“%d “,*(p+i));
    }

 

}
void sorting(int *p,int n)
{
    int temp,round;
    for( round=0;round<n-1;round++)
    {
        for(int i=0;i<n-round;i++)
        {
            if((p[i]>=p[i+1]))
            {
                temp=p[i];
                p[i]=p[i+1];
                p[i+1]=temp;
            }
        }
    }
}

2.reversing array using structure:

#include<stdio.h>
#include<stdlib.h>
struct x{
   int *p,n,start,end;
};
struct x* input( struct x *s1);
  struct x* reverse(struct x *s1);
   struct x* display( struct x *s1);
  int main()
  {
       struct x   *s1;
       s1=(struct x*)malloc(sizeof(struct x));
       printf(“how many number you want to insert in array\n”);
       scanf(“%d”,&s1->n);
       s1->p= (int *)malloc(sizeof(int)*s1->n);
       s1->start=0;
       s1->end=s1->n-1;
       s1=input(s1);
      return 0;
  }
    struct x* reverse(struct x *s1)
  { int temp;
        while(s1->start<s1->end)
    {
         temp=s1->p[s1->start];
        s1->p[s1->start]=s1->p[s1->end];
        s1->p[s1->end]=temp;
        s1->start++;
        s1->end–;
    }
      s1=display(s1);
  }
  struct x* input( struct x *s1)
  {
      printf(“enter the number\n”);
    for(int i=0;i<s1->n;i++)
    {
        scanf(“%d”,&s1->p[i]);
    }
    s1=reverse(s1);
    return(s1);
  }
  struct x* display( struct x *s1)
  { printf(“dsiplay the number\n”);
       for(int i=0;i<s1->n;i++)
    {
        printf(“%d “,s1->p[i]);
    }
    return(s1);
  }

3. dynamic memory allocations in c:

#include <stdio.h>
#include<conio.h>
struct temparature
{
    int mintemp,maxtemp;
};
int main()
{
  struct temparature t;
  int *days,n;
  printf(“enter the no of days\n”);
  scanf(“%d”,&n);
  days=(int *)malloc(sizeof(int)*n);
  for(int i=0;i<n;i++)
     {
         scanf(“%d”,(days+i));
     }
  avgtemp(days,n,t);
    return 0;
}
 void avgtemp(int *days,int n,struct temparature t)
 {
     int s=0;
     for(int i=0;i<n;i++)
     {
         s=s+days[i];
     }
     t.mintemp=s/n;
     printf(“%d”,t.mintemp);
 }

4.fibonacci using c:

#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
struct fibo {
     int n,t1,t2,s;
};
 void fibonacci(struct fibo);
int main()
{
    struct fibo n1;
   printf(“enter the mumber\n”);
    scanf(“%d”,&n1.n);
    fibonacci(n1);
}
 void fibonacci(struct fibo n1)
 {
   n1.t1=-1;n1.t2=1;n1.s;
    for (int i = 0; i <=n1.n; i++)
    {
        n1.s=n1.t1+n1.t2;
        n1.t1=n1.t2;
        n1.t2=n1.s;
    printf(“%d\n”,n1.s);
    }
 }

5. sorting programs:

#include<stdio.h>
void input( int *p, int n );
void display(int *p,int n);
void sort(int *p,int n);
int main()
{
 int arr[20],n;
 printf(“enter the number of  values”);
 scanf(“%d”,&n);
 input(arr,n);
return 0;
}
void input( int *p, int n )
{
    printf(“enter the  elements”);
 for(int i =0;i<n; i++)
 scanf(“%d”,p+i);
  display( p,n);//p=arr=&arr[0]
   sort(p,n);
   }
void display(int *p,int n)
{
    printf(“display the elements”);
    for(int i =0;i<n; i++)
    printf(“%d\n”,*(p+i));
}
   void sort(int *p,int n)
   {
       int temp;
       for(int r=0;r<=n-1;r++)
{      for(int i=0;i<n-1;i++)
        {
            if(*(p+i)>=*(p+i+1))
            {
                temp=*(p+i);
                *(p+i)=*(p+i+1);
                *(p+i+1)=temp;
            }
        }
      }
       display( p,n);
}

array and pointers concept descriptions breifly

195 thoughts on “array and pointers uses in c that you should know in programming”

  1. It’s really a nice and useful piece of information. I am glad that you simply shared this helpful information with us.

    Please keep us up to date like this. Thanks for sharing.

    My website :: Pat

    Reply
  2. I’ve learn several just right stuff here. Definitely worth bookmarking for revisiting.

    I surprise how a lot attempt you put to make any such fantastic informative site.

    Reply
  3. Thanks for the sensible critique. Me & my neighbor were just
    preparing to do a little research about this. We got a grab a book from our area library
    but I think I learned more from this post. I am
    very glad to see such fantastic information being shared
    freely out there.

    Visit my homepage … eating healthy foods

    Reply
  4. Hey this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience.
    Any help would be greatly appreciated!

    Have a look at my web-site – sex pills

    Reply
  5. Hi there, I discovered your site by the use of Google whilst searching for a similar subject, your site
    came up, it appears to be like great. I’ve bookmarked it in my google bookmarks.[X-N-E-W-L-I-N-S-P-I-N-X]Hi there,
    just changed into aware of your weblog through Google, and located that it is really informative.
    I’m going to watch out for brussels. I will be grateful for those who proceed this in future.
    A lot of other people shall be benefited out of your writing.
    Cheers!

    Feel free to visit my website … cannabis doctor – http://www.fotosombra.com.br

    Reply
  6. I’m not that much of a online reader to be honest but your sites really nice, keep it up!
    I’ll go ahead and bookmark your site to come back down the
    road. All the best

    Reply
  7. Very nice post. I just stumbled upon your weblog and wanted to mention that I’ve
    really enjoyed surfing around your blog posts.
    After all I’ll be subscribing for your rss feed and I hope you write again very soon!

    my page :: drug use

    Reply
  8. Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just extremely fantastic.
    I really like what you have acquired here, really like what you are stating and the way in which you
    say it. You make it enjoyable and you still take care of to keep it wise.
    I cant wait to read far more from you. This is really a tremendous web site.

    my site … fat burning kitchen

    Reply
  9. My partner and I absolutely love your blog and find many of your post’s to be exactly what
    I’m looking for. Do you offer guest writers to write content for you?

    I wouldn’t mind composing a post or elaborating on some
    of the subjects you write concerning here.

    Again, awesome site!

    Reply
  10. Hiya, I am really glad I’ve found this information. Nowadays bloggers publish only about gossips and
    web and this is really irritating. A good blog with exciting content, that is
    what I need. Thank you for keeping this web site, I’ll be visiting it.
    Do you do newsletters? Cant find it.

    Look at my web site cyclical ketogenic

    Reply
  11. Greetings from California! I’m bored to tears at
    work so I decided to check out your website on my iphone
    during lunch break. I enjoy the info you provide here and can’t wait to take a look when I get home.
    I’m surprised at how fast your blog loaded on my phone ..
    I’m not even using WIFI, just 3G .. Anyhow, awesome site!

    Reply
  12. Hi there, I do believe your blog could possibly be having browser compatibility problems.
    When I take a look at your web site in Safari, it looks fine but when opening in I.E., it’s got some overlapping issues.
    I just wanted to provide you with a quick heads up!

    Other than that, fantastic website!

    My site; healthy eating diets

    Reply
  13. You really make it appear so easy with your presentation but I find this matter to
    be really one thing which I feel I might never understand.
    It sort of feels too complex and extremely vast
    for me. I am having a look ahead in your next post, I’ll attempt to get the grasp of it!

    Review my page: children smoking

    Reply
  14. I wanted to check up and allow you to know how much I cherished
    discovering your blog today. I’d consider it a real honor
    to operate at my workplace and be able to use
    the tips provided on your site and also be a part of visitors’
    responses like this. Should a position involving guest article writer become available at your end, i highly recommend you let me know.

    Check out my site; best sex in marriage

    Reply
  15. Link exchange is nothing else except it is just placing the
    other person’s web site link on your page at proper place and other person will also do same in favor of
    you.

    Reply
  16. That is a great tip particularly to those new to the blogosphere.
    Brief but very accurate information? Appreciate your sharing this one.
    A must read article!

    Here is my web blog :: acne skin care (Fanny)

    Reply
  17. I was suggested this blog through my cousin. I’m no longer
    certain whether or not this publish is written via him as no one else recognize such
    particular approximately my trouble. You are amazing!
    Thanks!

    Reply
  18. Great goods from you, man. I have understand your stuff previous to and you’re just too fantastic.
    I actually like what you have acquired here, really like what
    you’re stating and the way in which you say it. You make it enjoyable and
    you still take care of to keep it sensible. I cant wait to read much more
    from you. This is actually a terrific site.

    Reply
  19. I know this if off topic but I’m looking into starting my own weblog and was wondering what
    all is needed to get set up? I’m assuming having
    a blog like yours would cost a pretty penny? I’m not very web smart so I’m not 100% certain. Any recommendations or advice would
    be greatly appreciated. Kudos

    Review my blog post – 23.95.102.216

    Reply
  20. I’m not sure where you’re getting your information, but great topic.

    I needs to spend some time learning much more or understanding more.
    Thanks for fantastic information I was looking for this info for my mission.

    Reply
  21. Hello, i think that i saw you visited my blog thus i got here to ?return the want?.I am trying to to find issues to enhance my web site!I guess its adequate
    to use a few of your ideas!!

    Review my web site … fat burn

    Reply
  22. Woah! I’m really loving the template/theme of
    this blog. It’s simple, yet effective. A lot of times
    it’s tough to get that “perfect balance” between superb usability and
    visual appeal. I must say that you’ve done a awesome job
    with this. Additionally, the blog loads extremely quick for me
    on Chrome. Exceptional Blog!

    Reply
  23. My programmer is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using WordPress on several websites for about
    a year and am worried about switching to another platform.
    I have heard excellent things about blogengine.net.
    Is there a way I can transfer all my wordpress content into it?
    Any help would be greatly appreciated!

    Here is my site: http://mainsevents.com/

    Reply
  24. You can definitely see your enthusiasm within the article you write.
    The arena hopes for more passionate writers such as you who are
    not afraid to mention how they believe. At all times follow your heart.

    Feel free to visit my web site – drug crime

    Reply
  25. Have you ever considered about including a little bit more than just
    your articles? I mean, what you say is fundamental and all.
    However just imagine if you added some great visuals or videos to give
    your posts more, “pop”! Your content is excellent but with images and clips,
    this site could undeniably be one of the most beneficial in its niche.
    Wonderful blog!

    Reply
  26. Hey There. I discovered your weblog using msn. That is a really neatly written article.
    I will be sure to bookmark it and come back to read extra of your useful info.
    Thank you for the post. I’ll definitely return.

    Review my webpage: quit smoking

    Reply
  27. Its such as you learn my thoughts! You appear to understand so much approximately this, such
    as you wrote the book in it or something. I feel that you simply
    could do with some % to force the message home a little bit, but instead
    of that, that is magnificent blog. A fantastic read.
    I will certainly be back.

    Reply
  28. I keep listening to the reports talk about receiving
    free online grant applications so I have been looking around
    for the finest site to get one. Could you advise me please, where could i acquire some?

    Also visit my website – oily skin

    Reply
  29. Awesome blog! Do you have any helpful hints for aspiring writers?
    I’m planning to start my own website soon but I’m a little lost on everything.
    Would you propose starting with a free platform like
    Wordpress or go for a paid option? There are so many choices out there that I’m totally confused
    .. Any recommendations? Many thanks!

    Feel free to visit my blog post – hair loss

    Reply
  30. I believe everything posted was actually
    very logical. But, think about this, suppose you added a
    little content? I am not suggesting your information isn’t good,
    however what if you added a title that grabbed people’s attention?
    I mean array and pointers uses in c that you should know in programming – LMT is a little
    vanilla. You ought to look at Yahoo’s front page and watch how they create
    news titles to grab people interested. You might add a related video or
    a picture or two to get people excited about everything’ve written. Just my opinion, it
    would make your website a little bit more interesting.

    My web page; medical cannabis

    Reply
  31. Hey! I understand this is kind of off-topic however I needed to ask.
    Does building a well-established website like yours take a large amount of work?

    I am completely new to running a blog however I do write in my
    diary everyday. I’d like to start a blog so I
    can easily share my own experience and feelings online.
    Please let me know if you have any kind of suggestions or
    tips for brand new aspiring bloggers. Thankyou!

    My web site http://www.aniene.net

    Reply
  32. Greetings I am so happy I found your blog, I really
    found you by error, while I was browsing on Aol for something else,
    Nonetheless I am here now and would just like to say many thanks for a marvelous post and a all round thrilling blog (I also love the theme/design), I don?t have time to read
    it all at the minute but I have saved it and also added your RSS feeds,
    so when I have time I will be back to read much more, Please do keep up the excellent work.

    Here is my site – skin care p

    Reply
  33. Good site! I really love how it is simple on my eyes and the data are well written. I am wondering how
    I might be notified when a new post has been made.
    I’ve subscribed to your RSS which must do the trick! Have a great day!

    my web page :: fat loss

    Reply
  34. Admiring the persistence you put into your
    site and in depth information you provide. It’s nice to come
    across a blog every once in a while that isn’t
    the same old rehashed material. Excellent read! I’ve bookmarked your site and I’m including your RSS
    feeds to my Google account.

    my blog post: cannabis doctors

    Reply
  35. Hi there would you mind sharing which blog platform you’re using?
    I’m going to start my own blog soon but I’m having a
    tough time selecting between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design seems different then most
    blogs and I’m looking for something completely unique.
    P.S My apologies for getting off-topic but I had to ask!

    Review my site … low libido cures

    Reply
  36. I know this if off topic but I’m looking into starting my own weblog and was wondering what
    all is required to get setup? I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very web savvy so I’m not 100% positive. Any suggestions or advice would
    be greatly appreciated. Kudos

    Visit my site; hemp seed oil capsules

    Reply
  37. I’m not sure where you are getting your information, however great topic.
    I needs to spend a while finding out much more or
    understanding more. Thank you for fantastic information I used to be on the lookout for this information for my mission.

    My blog post: grow weed

    Reply
  38. Oh my goodness! Awesome article dude! Thank you so much, However I am encountering problems with your RSS.
    I don’t know why I am unable to subscribe to it. Is there anyone else getting similar RSS
    issues? Anybody who knows the solution can you kindly respond?
    Thanks!!

    Here is my homepage … anti aging

    Reply
  39. Hi there this is kind of of off topic but I was wondering
    if blogs use WYSIWYG editors or if you have to manually code with HTML.

    I’m starting a blog soon but have no coding know-how so I wanted
    to get advice from someone with experience. Any help
    would be greatly appreciated!

    Reply
  40. Hello there! I could have sworn I?ve visited your
    blog before but after browsing through many of the articles I realized it?s new to me.
    Regardless, I?m certainly delighted I stumbled
    upon it and I?ll be book-marking it and checking back often!

    Also visit my homepage: cycling diet

    Reply
  41. I have been browsing online more than 4 hours today, yet I never
    found any interesting article like yours. It’s pretty worth enough for
    me. In my opinion, if all web owners and bloggers made good content as you did, the internet will be
    a lot more useful than ever before.

    my website :: low libido cures

    Reply
  42. hello there and thank you for your info – I’ve certainly picked up anything new from right here.
    I did however expertise a few technical points using this website, as I experienced to reload
    the web site a lot of times previous to I could get it to
    load properly. I had been wondering if your web hosting is OK?
    Not that I’m complaining, but slow loading instances times will very frequently affect your placement in google
    and can damage your quality score if advertising and marketing with Adwords.

    Well I’m adding this RSS to my e-mail and could look out for much more
    of your respective exciting content. Make sure you update this again soon..

    Feel free to visit my homepage: freshly hatched seeds

    Reply
  43. My coder is trying to persuade me to move to .net from PHP.
    I have always disliked the idea because of the costs. But he’s tryiong none
    the less. I’ve been using Movable-type on a variety of websites for about a year
    and am anxious about switching to another platform.
    I have heard good things about blogengine.net. Is
    there a way I can import all my wordpress content into it?

    Any help would be greatly appreciated!

    My homepage Jamal

    Reply
  44. Hey I know this is off topic but I was wondering if you knew of any widgets I
    could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this
    for quite some time and was hoping maybe you would have some
    experience with something like this. Please let me know if you run into anything.

    I truly enjoy reading your blog and I look forward to your new updates.

    Also visit my blog post growing inside

    Reply
  45. After checking out a handful of the blog articles on your site, I honestly
    like your technique of writing a blog. I added it to my bookmark site list
    and will be checking back in the near future. Please check out
    my website too and let me know how you feel.

    Check out my page easy diet

    Reply
  46. Oh my goodness! Amazing article dude! Many thanks, However I am experiencing
    problems with your RSS. I don?t understand why I am unable
    to subscribe to it. Is there anyone else having identical RSS problems?
    Anybody who knows the solution will you kindly respond?
    Thanx!!

    Stop by my web site … fenshuajiang88.com

    Reply
  47. Hey! I understand this is sort of off-topic but I needed to ask.
    Does building a well-established blog like yours take a massive amount work?

    I am completely new to writing a blog but I do write in my journal daily.
    I’d like to start a blog so I can share my experience
    and views online. Please let me know if you have any kind of ideas or
    great sex tips for new aspiring blog owners.
    Appreciate it!

    Reply
  48. Right here is the perfect web site for everyone who wishes
    to find out about this topic. You realize a
    whole lot its almost tough to argue with you (not that
    I personally would want to…HaHa). You certainly put a new spin on a subject which has been written about for many
    years. Excellent stuff, just wonderful!

    Feel free to visit my website – propane patio heaters

    Reply
  49. You could definitely see your expertise within the work you write.
    The arena hopes for even more passionate writers such as you who aren’t afraid to say how they believe.

    All the time follow your heart.

    Reply

Leave a Comment