Home

In this blog you can learn C,C++,Data Structurs and OS concepts learn very easy.Every concept is explain by through a program. so you can adapt very quickly.
Freshers and Experienced people who are attend a written test ,go through mcqs in this blog you can crack exam very easily.

1.C

2.C++

3.Data Structures

4.Logics

 




































0 comments:



HOW TO CONNECT PUTTY TO VMWARE

1. Go to Virtual Network Editor

2.click on “NAT” . In the above screen shot “NAT” is available Vmnet8.

3.clik on the “NAT settings”.

4.note down “GATE WAY” ip address . for example see the above screen. 


5.close.

6.click on "DHCP settings".

7. note down “start ip add”, “end ip add”.

8.close.

9.note down “subnet mask”.

10.go to “VM WARE”.

11.edit below file.

“vim /etc/sysconfig/network-scripts/ifcfg-eth0

12.while edit the above file you are in root mode.

13. chek that fields like below.oherwise change your fields like a below. 


BOOTPROTO=static

ONBOOT =yes
 GATEWAY = 192.168.204.2 (“enter your note down gateway address” )
 IPADDR = 192.168.204.8 
SUBNETMASK =192.168.204.0 

14. save.

15.restart.

16.login putty.

17. enter ip address.

18.select “ssh” mode.

19.ok

0 comments:

#include<stdio.h>
main()
{
        int a[5] = {55,11,66,77,72};
        int max,min,i;
        int smax,smin;
        max = min = a[0];
        smax = smin = a[0];
        for(i=0;i<=4;i++)
        {
                if(a[i]>max)
                {
                        smax = max;
                        max = a[i];
                }
                if(max>a[i]&&smax<a[i])
                {
                        smax = a[i];
                }
        }
        printf("the first max element z %d\n",max);
        printf("the second max element z %d\n",smax);
}

0 comments:





#include<stdio.h>
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

0 comments:


Inline functions :
#include
using namespace std;
class A
{
public:
void fun();
};
inline void A::fun()
{
cout&lt;&lt;"this is inline function\n";
}
main()
{
A a;
a.fun();
}
Op :
this is inline function.
#include
using namespace std;
inline int add(int x,int y)
{
int r;
r = x + y;
}
main()
{
cout&lt;
}
Op :
30

0 comments:

4.2 Difference between Structure and Union



#include<stdio.h>

union un{

        int i;

        char ch;

        float f;

}

main()

{

        union un u1;

        u1.i = 10;

        u1.ch = 'a';

        u1.f = 1.9999;

        printf("%d %c %f ",u1.i,u1.ch,u1.f);

}


Op :

1073740985 ¹ 1.999900

0 comments:

3.4 Difference between passing structure by value and by pointer

By Value :



#include<stdio.h>

struct node

{
        int date;
        int num;
        char name;
};
void fun(struct node n);

main()
{
        struct node n;
        fun(n);
}
void fun(struct node n1)
{
        n1.date = 10;
        n1.num  = 99;
        n1.name = 'a';
        printf("%d %d %c\n",n1.date,n1.num,n1.name);
        printf("size of node = %d\n",sizeof(struct node));

}

op:

10 99 a
size of node = 12
Note : passing a structure it takes 12 bytes
 ------------------------------------------------------------------------------------------------------------------------------------
 By Pointer :


#include<stdio.h>

struct node

{

        int date;

        int num;

        char name;

};

void fun(struct node *n);



main()

{

        struct node n;

        fun(&n);

}

void fun(struct node *n1)

{

        n1->date = 10;

        n1->num  = 99;

        n1->name = 'a';

        printf("%d %d %c\n",n1->date,n1->num,n1->name);

        printf("size of node = %d\n",sizeof(n1));



}


Op :

10 99 a

size of node = 4


Note : passing a pointer it takes only 4 bytes.

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

Differences :

1 Structure passing through a pointer faster than passing through a value.

2 Structure passing through a pointer we saves the memory. Because structure passing through a pointer it takes only 4 bytes in above program.The same program strucutre passing through a value it takes 12 bytes.
    

0 comments:

3.3 Passing Structure by Pointer



#include<stdio.h>
struct node
{
        int date;
        int num;
        char name;
};
void fun(struct node *n);

main()
{
        struct node n;
        fun(&n);
}
void fun(struct node *n1)
{
        n1->date = 10;
        n1->num  = 99;
        n1->name = 'a';
        printf("%d %d %c\n",n1->date,n1->num,n1->name);
        printf("size of node = %d\n",sizeof(n1));

}




Op :

10 99 a

size of node = 4
 

0 comments: