• Home
  • C
  • DS
  • Logics
  • C mcq
  • OS
  • C++
  • TECHNOLOGY

Learn C and C++

  • Home
  • Category 1
  • Category 2
    • This is a dropdown
    • This is a dropdown
      • This is a dropdown
      • This is a dropdown
    • This is a dropdown
    • This is a dropdown
  • Category 3
  • Category 4
  • Typography
  • Shortcodes
  • RSS

C

1.Data Structures

1.1 what is Data Structure ?

1.2 Types of Data Structures?

2.Arrays

2.1 what is Arrays ?

2.2 Adavantages and Disadvantages of Arrays ?

2.3 Array initialization

3.Structures

3.1 what is Structure ?

3.2 Passing Structure by value

3.3 Passing Structure by Pointer

3.4 Difference between passing structure by value and by pointer

4.Union 

4.1 what is union ?

4.2 Difference between Structure and Union






























Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

0 comments:

Home
Subscribe to: Posts (Atom)

Follow Us

  • Twitter
  • Facebook
  • Tumblr
  • YouTube
  • Vimeo
  • LinkedIn
  • Behance
  • Envato
  • iCloud
  • Evernote
  • Gowalla
  • Paypal
  • Pinterest
  • Quora
  • Google
  • Googleplus
  • Github
  • Dribbble
  • Flickr
  • WordPress
  • RSS

For Scroll Down use "ARROWS"

Popular Posts

    find the second smallest element in the array
    Queue implemented as a linked list
    2.Arrays
    (no title)
    1.Data Structures
    Bitwise operators
    reverse printing of the string
    reverse of the string
    stack
    (no title)

Labels

  • arrays logics

About


#include
struct node
{
int data;
struct node* next;
};
void addatbeg(struct node**,int);
void append(struct node**,int);
void display(struct node*);
void delete(struct node**,int num);
void count(struct node*);
void insert(struct node**,int,int);
void reverse(struct node**);
void reversing(struct node*);
void mid(struct node*);
main()
{
struct node *head;
head = NULL;
addatbeg(&head,10);
addatbeg(&head,20);
addatbeg(&head,30);
display(head);
append(&head,60);
append(&head,70);
printf("\n");
display(head);
delete(&head,60);
printf("\n");
printf("after deletion the linked list be a\n");
display(head);
printf("\n");
printf("the number of nodes will be\n");
count(head);
insert(&head,333,20);
printf("\n");
display(head);
reverse(&head);
printf("\n");
printf("this is reverse the nodes\n");
display(head);
reversing(head);
printf("\n");
printf("this is reverse printing\n");
display(head);
printf("\n");
printf("the mid element is\n");
mid(head);


}
void addatbeg(struct node **q,int num)
{
struct node *temp;
temp = (struct node*)malloc(sizeof(struct node));
temp->data = num;
temp->next = *q;
*q = temp;
}
void display(struct node *q)
{
while(q!=NULL)
{
printf("%d ",q->data);
q = q->next;
}
}
void append(struct node**q,int num)
{
struct node *temp,*r;
if(q==NULL)
{
temp = (struct node*)malloc(sizeof(struct node));
temp->data = num;
temp->next = *q;
*q = temp;
}
else
{
temp = *q;
while(temp->next!=NULL)
temp = temp->next;
r = (struct node*)malloc(sizeof(struct node));
r->data = num;
r->next = NULL;
temp->next = r;
}
}
void delete(struct node **q,int num)
{
struct node* temp,*old;
temp = *q;
while(temp!=NULL)
{
if(temp->data == num)
{
if(temp == *q)
{
*q = NULL;
free(temp);
}
else
{
old->next = temp->next;
free(temp);
}
}
else
{



old = temp;
temp = temp->next;
}


}
}
void count(struct node*q)
{
int c=0;
while(q!=NULL)
{
c++;
q = q->next;
}
printf("the nuber of nodes = %d\n",c);

}
void insert(struct node**q,int num,int n)
{
struct node *temp,*r;
temp = *q;
while(temp!=NULL)
{
if(temp->data == n)
{
r = (struct node*)malloc(sizeof(struct node));
r->data = num;
r->next = temp->next;
temp->next = r;
}
temp = temp->next;
}
}
void reverse(struct node**q)
{
struct node *temp,*prev=NULL,*rev;
temp = *q;
while(temp!=NULL)
{
rev = temp;
temp = temp->next;
rev->next = prev;
prev = rev;
}
*q = rev;
}
void reversing(struct node*q)
{
if(q==NULL)
{
reversing(q->next);
printf("%d ",q->data);
}
}
void mid(struct node*q)
{
int m=0;
if(q->next==NULL)
{
printf("only one node is there\n");
}
if(q->next->next==NULL)
{
printf(" two nodes is there\n");
}
while( (q->next!=NULL) && (q->next->next!=NULL))
{
m++;
q = q->next;
}
printf("%d\n",m);
}

-------------------------------------------------------------------------------------------------------------------------------------------------

30 20 10
30 20 10 60 70
after deletion the linked list be a
30 20 10 70
the number of nodes will be
the nuber of nodes = 4

30 20 333 10 70
this is reverse the nodes
70 10 333 20 30
this is reverse printing
70 10 333 20 30
the mid element is
3

Link list 2

  • arrays logics (3)

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments
  • Link 1
  • Link 2
  • Link 3
  • Link 4
  • Link 5
  • Link 6
  • Link 7
Powered by Blogger.

Link list 3

  • arrays logics (3)

Pages - Menu

  • Home
  • C
  • DS
  • Logics
  • C mcq
  • OS
  • C++

About Me

prawin
View my complete profile

Followers

Blog Archive

  • ▼  2013 (29)
    • ▼  April (1)
      • Home
    • ►  March (2)
    • ►  February (11)
    • ►  January (15)

WpMag

Tags

  • arrays logics (3)

Flickr Feed

Free Autom Backlink Generator
Blogger Template by Clairvo Yance
Copyright © 2012 Learn C and C++ and Best Blog Themes.