• 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

Logics

BITWISE OPERATORS

1. decimal to binary convertion 



2. number multiply by2 with out using * operator


Arrays 

1.find the biggest and smallest element in the array

 

2.find the second biggest element in the array 

 

3.find the second smallest element in the array


Strings

1.find the length of the string

 

2.reverse printing the string

 

3.reverse of the string

 

4.delete the particular character in a string

 


Programs on a Linked lists 

 

1. adding the node at the begining  of the linked list

 

2. adding the node at the end of the linked list

 

3. display the contents of the linked list

 

4. delete the particular node in linked list

 

5. count the number of nodes in a linked list

 

6. insert node in a linked list

 

7. reverse the nodes in a linked list

 

7. printing the linked list in reverse way

 

8. finding the middle element of a linked list

 

Programs on a searching

 

1.Linear search

 

2.Binary search  

 


sorting











































































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.