An Overview

All the necessary study material for b-tech students.

What we have to offer you.

Codes,Syllabus,Study material,Lab manuals,Assignments and many more . . .

Surfing becomes easy.

You can have any material from our website and post your valuable comments for further improvement.

Get the latest techno news

Get yourself updated with this fast changing dynamic world and all the changes in b-tech pattern.

All the best resources for you.

We have done our level best to provide you with the best of the degree and thus this site is devoted to b-tech exclusively.

Showing posts with label 3rd semester. Show all posts
Showing posts with label 3rd semester. Show all posts

15 November 2011

A DSA program using student as an object.


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct student
{
int tot;
int rollno;
char name[10];
int marks;
struct student *next,*pre;
};
void main()
{
 int sub1,sub2,sub3,sub4,sub5;
 int tot;
 struct student *start,*ptr;
 char ch='y';
 start=NULL;
 clrscr();
 while(ch=='y')
 {
    if(start==NULL)
    {
start=ptr=malloc (sizeof (struct student));
start->pre=ptr;
    }
    else
    {
    ptr->next=malloc (sizeof (struct student));
    ptr->next->pre=ptr;
    ptr=ptr->next;
    }
    ptr->next=NULL;
    printf("\n enter any rollno :");
    scanf("%d",& ptr->rollno);
    printf("\n enter name :");
    scanf("%s",& ptr->name);
    printf("\n enter marks of 1st subject :");
    scanf("%d",& sub1);
    printf("\n enter marks of 2nd subject :");
    scanf("%d",& sub2);
    printf("\n enter marks of 3rd subject :");
    scanf("%d",& sub3);
    printf("\n enter marks of 4th subject :");
    scanf("%d",& sub4);
    printf("\n enter marks of 5th subject :");
    scanf("%d",& sub5);
    ptr->tot=sub1+sub2+sub3+sub4+sub5;
    printf("\n Total marks of a student is  : %d",ptr->tot);
    printf("\n \n enter your choice (y/n):");
    fflush(stdin);
    scanf("%c",& ch);
 }
for(ptr=start;ptr!=NULL;ptr=ptr->next)
{
printf("\n\n Rollno. of a student : %d",ptr->rollno);
printf("\n Name of a student : %s",ptr->name);
printf("\n Total marks of a student : %d",ptr->tot);
}
getch();
}

A DSA program of stacking.


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct node
{
int info;
struct node *next;
};
struct stack
{
struct stack *top,*next;
};
void main()
{
char ch='y';
struct node *node1;
struct stack *stack1;
stack1->top=NULL;
while(ch=='y')
{
node1=malloc(sizeof (struct node));
if(stack1->top==NULL)
{
node1->next=NULL;
}
else
{
node1->next=NULL;
}
      // stack1=node1;
printf("\n Enter any value");
scanf("%d",& node1->info);
printf("\n Enter your choice (y/n):");
fflush(stdin);
scanf("%c", &ch);
}
for(  ;stack1->top!=NULL;stack1->top=stack1->top->next)
{
printf("%d",node1->info);
}
getch();
}

14 November 2011

A simple class program in C++ to division using classes.

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class div
{
private:
int no1,no2;
public:
void getdata()
{
cout<<"\n Enter the 1st number :";
cin>>no1;
cout<<"\n Enter the 2nd number :";
cin>>no2;
}
void putdata()
{
cout<<"\n \n The 1st number is "<<no1;
cout<<"\n \n The 2nd number is "<<no2;
}
int caldiv()
{
int div1;
if(no1>no2)
{
div1=no1/no2;
}
else
{
div1=no2/no1;
}
return(div1);
}
};
void main()
{
int num;
clrscr();
div d;
d.getdata();
d.putdata();
num=d.caldiv();
cout<<"\n \n The division of two numbers is "<<num;
getch();
}

A simple class program in C++ to multiply using classes.

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class mul
{
private:
int no1,no2;
public:
void getdata()
{
cout<<"\n Enter the 1st number :";
cin>>no1;
cout<<"\n Enter the 2nd number :";
cin>>no2;
}
void putdata()
{
cout<<"\n \n The 1st number is "<<no1;
cout<<"\n \n The 2nd number is "<<no2;
}
int calmul()
{
int mul1;
mul1=no1*no2;
return(mul1);
}
};
void main()
{
int num;
clrscr();
mul m;
m.getdata();
m.putdata();
num=m.calmul();
cout<<"\n \n The multiplication of two numbers is "<<num;
getch();
}


A program using classes to get the mod.

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class mod
{
private:
int no1,no2;
public:
void getdata()
{
cout<<"\n Enter the 1st number :";
cin>>no1;
cout<<"\n Enter the 2nd number :";
cin>>no2;
}
void putdata()
{
cout<<"\n \n The 1st number is "<<no1;
cout<<"\n \n The 2nd number is "<<no2;
}
int calmod()
{
int mod1;
mod1=no1%no2;
return(mod1);
}
};
void main()
{
int num;
clrscr();
mod m;
m.getdata();
m.putdata();
num=m.calmod();
cout<<"\n \n The modulus of two numbers is "<<num;
getch();
}

A program in class array (C++)

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class array
{
private:
int arr1[5];
public:
void getdata();
void putdata();

};
void array::getdata()
{
for(int i=0;i<=4;i++)
{
cout<<"\n Enter the number :";
cin>>arr1[i];
}
}
void array::putdata()
{
for(int i=0;i<=4;i++)
{
cout<<"\n"<<arr1[i];
}
}
void main()
{
array a;
clrscr();
a.getdata();
a.putdata();
getch();
}

A simple class program in C++

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class student
{
private:
int age;
char name[10];
public:
void getdata()
{
cin>>name;
cin>>age;
}
void putdata()
{
cout<<"Your name is "<<name;
cout<<"Your age is "<<age;
}
};
void main()
{
student st;
st.getdata();
st.putdata();
clrscr();



getch();
}