Showing posts with label GTU Programs. Show all posts
Showing posts with label GTU Programs. Show all posts

Sunday, April 17, 2011

Example of include directive to separate header and footer (GTU MCA-IV WTAD Practical 20)

Download zip file from link given below.

Download zip file

Generate marksheet of student from database using Servlet ( GTU MCA-IV WTAD Practical 16)

Download zip file from link given below.

Download zip file

Wednesday, February 23, 2011

Saturday, August 21, 2010

Program to print 1 to 10 using while loop ( GTU Sem I Program No : 8)

/*Program to print 1 to 10 using while loop 
  Program No         :- 8 of GTU Practice Programs SEM I 
  Developed by       :- Malhar Vora 
  Developed on       :- 21/07/2010 
  Email              :- vbmade2000@gmail.com 
  Web Site           :- http://malhar2010.blogspot.com 
  Development Status :- Completed
**************************************************/  
void main()
{
     int n=1;

     while(n<=10){
 printf("%d\n",n);//Prints n
 n++; //Incrementing n
     }
}

Saturday, July 24, 2010

Program to get data from user and store in STUDENT file, again read it from STUDENT file and write to DATA file and display same on screen ( GTU Sem I Program No : 41)

/*Program to get student data from user,
  write it to STUDENT file , read it again in
  store in DATA file and display same on screen
  Program No   : 41 of GTU Practice Programs SEM I
  Developed by : Malhar Vora
  Developed on : 21/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
**************************************************/


struct studata
{
   int rollno;
   char name[20];
};

typedef struct studata student;
student s;

//Get Student data from user
void readData()
{
    short temp;
    printf("Enter Roll No of Student :");
    scanf("%d",&temp);
    s.rollno=temp;

    fflush(stdin);
    printf("\nEnter Name of Student :");
    gets(s.name);

}

//Write inputted data to STUDENT file
void writeStudentFile()
{
   FILE *stufile;
   stufile=fopen("STUDENT","wt");
   if(stufile==NULL)
   {
      printf("\nError in writing STUDENT file");
      return;
   }
   fwrite(&s,sizeof(s),1,stufile);
   fclose(stufile);
}

//Clear structure s to hold new data
void clearData()
{
   s.rollno=0;
   strcpy(s.name,"");
}

//Read data from STUDENT file
void readStudentFile()
{
   FILE *stufile;
   stufile=fopen("STUDENT","rt");
   if(stufile==NULL)
   {
      printf("\nError in reading STUDENT file");
      return;
   }
   fread(&s,sizeof(s),1,stufile);
   fclose(stufile);
}

//Write data to DATA file
void writeDataFile()
{
   FILE *datafile;
   datafile=fopen("STUDENT","wt");
   if(datafile==NULL)
   {
      printf("\nError in writing DATA file");
      return;
   }

   fwrite(&s,sizeof(s),1,datafile);
   fclose(datafile);
}

//Display data fetched from STUDENT file
void displayData()
{
   printf("\nData from STUDENT file");
   printf("\nRoll No : %d",s.rollno);
   printf("\nName    : %s",s.name);
}

void main()
{
  clrscr();
  readData();
  writeStudentFile();
  clearData();
  readStudentFile();
  writeDataFile();
  displayData();
}


Thursday, July 22, 2010

Program to create linear linked list and print contents and total items( GTU Sem I Program No : 42)

/*Program to create a linear linked list interactively and print its
  content and total no of items in list
  Program No   : 42 of GTU Practice Programs SEM I
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
****************************************************************************/


#include

#define LIMIT 5

//structure to hold data and link to next node
struct node
{
   int data;
   struct node *next;
};


short count=0; //Gloab lcounter to count no of items in list
typedef struct node *listnode;

listnode root=NULL;

void insert(int newdata)
{
    listnode newnode,temp;
    newnode=(listnode)malloc(sizeof(listnode));
    newnode->data=newdata;
    temp=root;
    while(temp->next!=NULL)
    {
       temp=temp->next;
    }
    temp->next=newnode;
    newnode->next=NULL;
    count++;
}

void print()
{
   listnode temp;
   temp=root;
   printf("\nPrinting items");
   while(temp->next!=NULL)
   {
       temp = temp->next;
       printf("\n%d",temp->data);
   }
}

void printcount()
{
   printf("\nTotal %d items are stored in linked list",count);
}

void main()
{
   clrscr();
   insert(1);
   insert(2);
   insert(3);
   insert(4);

   print();

   printcount();

}

Program to find maximum element from 1D array ( GTU Sem I Program No : 19)

/*Program to find maximum element from 1D array
  Program No   : 19 of GTU Practice Programs SEM I
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
****************************************************************************/


#include

#define LIMIT 5

int getMax(int *arr,int n)
{
   int i,max;
   max=arr[i];
   for(i=0;i
   {
      if(arr[i]>max)
     max=arr[i];
   }
   return max;
}

void main()
{
   int arr[LIMIT],i,max=0;
   clrscr();

   printf("Enter elements in array :");
   for(i=0;i
   {
      scanf("%d",&arr[i]);
   }


   printf("Max is : %d",getMax(arr,LIMIT));

}

Function to check that no is prime or not ( GTU Sem I Program No : 30)

/*Write a fucntion prime which returns 1 is argument is prime no otherwise 0
  Program No   : 30 of GTU Practice Programs
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
****************************************************************************/


#include


short prime(int no)
{
    if(no % 2==0)
       return 0;
    else
       return 1;
}


void main()
{
   int no;
   printf("Enter a no :");
   scanf("%d",&no);
   if(prime(no)==1)
   {
      printf("\nNo is prime");
   }
   else
   {
      printf("\nNo is not prime");
   }

} 


Program to count length of given string ( GTU Sem I Program No : 23)

/*Program to find length of inputted string
  Program No   : 23 of GTU Practice Programs
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
****************************************************************************/


#include 

int strlen(char *str)
{
    int count=0;
    while(str[count]!=0)
      count++;
    return count;
}

void main()
{
   char *str;
   printf("Enter a string :");
   gets(str);
   printf("\nLength of string is : %d",strlen(str));
}