PRACTICAL : 1.
AIM : Write a program to insert 5 elements into an array and display it.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[5],i;
            clrscr();
            for(i=0;i<5;i++)
            {
                        printf("Enter the Elements= \n");
                        scanf("%d",&a[i]);
            }
            printf("The array Elements are= \n");
            for(i=0;i<5;i++)
            {
                        printf("\n %d",a[i]);
            }
            getch();
}

OUTPUT:
Enter the array element=
12
Enter the array element=
13
Enter the array element=
15
Enter the array element=
9
Enter the array element=
4
The array element are=
12
13
15
9
4

       PRACTICAL : 2.
AIM : Write a program to insert an elements into an array at the beginning of the array.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[100],n,i,no;
            clrscr();
            printf("Enter the Elements= \n");
            scanf("%d",&n);
            for(i=0;i<n;i++)
            {
                        scanf("%d",&a[i]);
            }
            printf("Enter the Elements Which Will be added at beggining of Array= \n");
            scanf("%d",&no);
            for(i=n-1;i>=0;i--)
            {
                        a[i+1]=a[i];
            }
            a[0]=no;
            printf("After Inseration Operation= \n");
            for(i=0;i<=n;i++)
            {
                        printf("%d \n",a[i]);
            }
            getch();
}
OUTPUT :
Enter the no of element=5
Enter the element=11
Enter the element=12
Enter the element=13
Enter the element=14
Enter the element=15
Enter the element which will be added at beginning=0
After inseration Operation=
0
11
12
13
14                                             
15

PRACTICAL : 3.
AIM : Write a program to insert an elements into an array at the ending of the array.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[100],n,i,no;
            clrscr();
            printf("Enter the Elements= \n");
            scanf("%d",&n);
            for(i=0;i<n;i++)
            {
                        scanf("%d",&a[i]);
            }
            printf("Enter the Elements Which Will be added at ending of Array= \n");
            scanf("%d",&no);
            a[n+1]=no;
            printf("After Inseration Operation= \n");
            for(i=0;i<=n;i++)
            {
                        printf("%d \n",a[i]);
            }
            getch();
}
OUTPUT :
Enter the no of element=5
Enter the element=11
Enter the element=12
Enter the element=13
Enter the element=14
Enter the element=15
Enter the element which will be added at ending=0
After inseration Operation=
11
12
13
14                                             
15
0

PRACTICAL : 4.
AIM : Write a program to insert an elements into an array at specific position of the array.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[100],i,n,no,position;
            clrscr();
            printf("Enter the no of Element= ");
            scanf("%d",&n);
            printf("Enter position= ");
            scanf("%d",&position);
            printf("Enter the Element which will be added at spesific position of array= ");
            scanf("%d",&no);
            for(i=n-i;i>position;i++)
            {
                        a[i+1]=a[i];
            }
            a[position-1]=no;
            printf("After Inseration Operasion=");
            for(i=0;i<=n;i++)
            {
                        printf("%d",a[i]);
            }
            getch();
}
OUTPUT :
Enter the no of element=5
Enter element of array=
11
12
13
14
15
Enter position =2
Enter element which will be added=16
After inseration operation=
11
16
12
13
14
15
PRACTICAL : 5.
AIM : Write a program to search a specific elements from the array and display its position.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[5]={10,20,30,40,50};
            int no,position,i,flag=0;
            printf("Enter the no=");
            scanf("%d",&no);
            for(i=0;i<5;i++)
            {
                        if(a[i]==no)
                        {
                                    position=i+1;
                                    flag=1;
                                    goto |b|;
                        }
            }
            |b|:
            if(flag==0)
            {
                        printf("%d",position);
            }
            else
            {
                        printf("No not Found");
            }
            getch();
}
OUTPUT :
Enter the no=30
Position=3
PRACTICAL : 6.
AIM : Write a program to merge two one dimensional array into third array.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[5]={5,15,25,35,45};
            int b[5]={10,20,30,40,50};
            int i,j=0,c[10];
            clrscr();
            for(i=0;i<5;i++)
            {
                        c[i]=a[i];
                        j++;
            }
            for(i=0;i<5;i++)
            {
                        c[i]=b[i];
                        j++;
            }
            printf("After Merge Operation Array Element Are= \n");
            for(i=0;i<10;i++)
            {
                        printf("%d \n",c[i]);
            }
            getch();
}
OUTPUT :
5
15
25
35
45
10
20
30
40
50

PRACTICAL : 7.
PRACTICAL : 7(A).
AIM : Write a program to short array element in ascending order.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[5]={5,15,2,35,4};
            int i,j,temp,n=5;
            clrscr();
            for(i=0;i<5;i++)
            {
                        for(j=i+1;j<5;j++)
                        {
                                    if(a[i] > a[j])
                                    {
                                                temp=a[i];
                                                a[i]=a[j];
                                                a[j]=temp;
                                    }
                        }
            }

            printf("Array Element are in ascending order= \n");
            for(i=0;i<n;i++)
            {
                        printf("%d \n",a[i]);
            }
            getch();
}
OUTPUT :
Array element in ascending order are given below=
2
4
5
15
35

PRACTICAL : 7(B).
AIM : Write a program to short array element in descending order.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[5]={5,15,2,35,4};
            int i,j,temp,n=5;
            clrscr();
            for(i=0;i<5;i++)
            {
                        for(j=i+1;j<5;j++)
                        {
                                    if(a[i] < a[j])
                                    {
                                                temp=a[i];
                                                a[i]=a[j];
                                                a[j]=temp;
                                    }
                        }
            }

            printf("Array Element are in Descending order= \n");
            for(i=0;i<n;i++)
            {
                        printf("%d \n",a[i]);
            }
            getch();
}
OUTPUT :
Array element in descending order are given below=
35
15
5
4
2

PRACTICAL : 8.
AIM : Write a program to delete an element into an array at the beginning of the array.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[5]={15,11,13,9,12};
            int i;
            clrscr();
            for(i=0;i<5;i++)
            {
                        a[i]=a[i+1];
            }
            a[4]=0;
            printf("After Deletion is beggining Operation= \n");
            for(i=0;i<4;i++)
            {
                        printf("%d \n",a[i]);
            }
            getch();
}
OUTPUT :
After deletion operation=
11
13
9
12

PRACTICAL : 9.
AIM : Write a program to delete an element into an array at the ending of the array.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[5]={15,11,13,9,12};
            int i;
            clrscr();
            a[4]=0;
            printf("After Deletion is ending Operation= \n");
            for(i=0;i<4;i++)
            {
                        printf("%d \n",a[i]);
            }
            getch();
}
OUTPUT :
After deletion operation=
15
11
9
13

PRACTICAL : 10.
AIM : Write a program to delete an element into an array at specific position of the array.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[5]={10,20,30,40,50};
            int i,position;
            clrscr();
            printf("Enter the position of element to be deleted= \n");
            scanf("%d",&position);
            for(i=position;i<5;i++)
            {
                        a[i-1]=a[i];
            }
            a[4]=0;
            printf("Array Element After Deletion Operation= \n");
            for(i=0;i<4;i++)
            {
                        printf("%d \n",a[i]);
            }
            getch();
}
OUTPUT :
Enter the positionof elementto be deleted=2
 Array element After deletion operation=
10
30
40
50

PRACTICAL : 11.
AIM : Write a program to Insert array elements in 3 x 3 matrix and display it.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[3][3],i,j;
            clrscr();
            printf("Enter the element of 3 x 3 matrix = \n");
            for(i=0;i<3;i++)
            {
                        for(j=0;j<3;j++)
                        {
                                    scanf("%d",&a[i][j]);
                        }
            }
            printf("Element of 3 x 3 matrix given below                                                     = \n");
            for(i=0;i<3;i++)
            {
                        for(j=0;j<3;j++)
                        {
                                    printf("%3d",a[i][j]);
                        }
                                    printf("\n");
            }
            getch();
}
OUTPUT :
Enter the Elements of 3 X 3 matrix :
1
2
3
4
5
6
7
8
9
Elements of 3 X 3 matrix given below :
1          2          3
4          5          6
7          8          9


PRACTICAL : 12.
AIM : Write a program to add two 3 x 3 matrix into third matrix .

#include<stdio.h>
#include<conio.h>
void main()
{
            int a[3][3],b[3][3],c[3][3],i,j;
            clrscr();
            printf("Enter the element of matrix a = \n");
            for(i=0;i<3;i++)
            {
                        for(j=0;j<3;j++)
                        {
                                    scanf("%d",&a[i][j]);
                        }
            }
            printf("Enter the element of matrix b = \n");
            for(i=0;i<3;i++)
            {
                        for(j=0;j<3;j++)
                        {
                                    scanf("%d",&b[i][j]);
                        }
            }
            for(i=0;i<3;i++)
            {
                        for(j=0;j<3;j++)
                        {
                                    c[i][j]=a[i][j] + b[i][j];
                        }
            }
            printf("Matrix c = \n");
            for(i=0;i<3;i++)
            {
                        for(j=0;j<3;j++)
                        {
                                    printf("%3d",c[i][j]);
                        }
                                    printf("\n");
            }
            getch();
}
OUTPUT :
Enter the Elements of  matrix  A :
1
1
1
1
1
1
1
1
1
Enter the Elements of  matrix  B :
1
1
1
1
1
1
1
1
1

3          3          3
3          3          3
3          3          3


PRACTICAL : 13.
AIM : Write a program to multiply 3 x 3 matrix into third matrix .
#include<stdio.h>
#include<conio.h>
void main()
{
            int a[3][3],b[3][3],c[3][3];
            int i,j,k,sum=0;
            clrscr();
            printf("Enter the element of matrix a = \n");
            for(i=0;i<3;i++)
            {
                        for(j=0;j<3;j++)
                        {
                                    scanf("%d",&a[i][j]);
                        }
            }
            printf("Enter the element of matrix b = \n");
            for(i=0;i<3;i++)
            {
                        for(j=0;j<3;j++)
                        {
                                    scanf("%d",&b[i][j]);
                        }
            }
            for(i=0;i<3;i++)
            {
                        for(j=0;j<3;j++)
                        {
                                    for(k=0;k<3;k++)
                                    {
                                                sum=sum+a[i][k] * b[k][i];
                                    }
                        }
            }
            for(i=0;i<n;i++)
            {
                        printf("%3d",a[i]);
            }
            getch();
}
OUTPUT :
Enter the Elements of  matrix  A :
1
2
3
2
3
1
2
2
2
Enter the Elements of  matrix  B :
2
4
6
3
2
1
3
6
4
Matrix c =
17                   26                   20
16                   20                   14
16                   24                   22


PRACTICAL : 14.
PRACTICAL : 14(A).
AIM : Write a program to display strong with different formats.

#include<stdio.h>
#include<conio.h>
void main()
{
            char city[20]={"ahmedabad"};
            clrscr();
            printf("%15s \n",city);
            printf("%-15s \n",city);
            printf("%15.5s \n",city);
            getch();
}
OUTPUT :
                        ahmedabad
ahmedabad
                                ahmed


PRACTICAL : 14(B).
AIM : Write a program to using sscanf function.

#include<stdio.h>
#include<conio.h>
void main()
{
            char name[50]={"Chauhan Harsh Vasantbhai"};
            char fname[10],mname[30],lname[10];
            clrscr();
            sscanf(name,"%s %s %              s",lname,fname,mname);
            printf("First name = %s \n",fname);
            printf("Middle name = %s \n",mname);
            printf("Last name = %s \n",lname);
            getch();
}
OUTPUT :
First name = Harsh
Middle name = Vasantbhai
Last name = chauhan


PRACTICAL : 14(C).
AIM : Write a program to using sprintf function.
#include<stdio.h>
#include<conio.h>
void main()
{
            char fname[10]={"Harsh"};
            char mname[30]={"Vasantbhai"};
            char lname[10]={"Chauhan"};
            char name[70];
            clrscr();
            sprintf(name,"%s %s % s", lname , fname , mname);
            puts(name);
            getch();
}
OUTPUT :
Chauhan Harsh Vasantbhai


PRACTICAL : 15.
AIM : Write a program to find the length of string using string function.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
            char name[100]={"harsh"};
            int n;
            clrscr();
            n=strlen(name);
            printf("length of string=%d",n);
            getch();
}
OUTPUT :
length of string = 5.


PRACTICAL : 16.
AIM : Write a program to copy one string into another string using string function.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
            char dept[20]={"computer"};
            char department[20];
            clrscr();
            strcpy(department,dept);
            printf("department=%s",department);
            getch();
}
OUTPUT :
department = computer


PRACTICAL : 17.
AIM : Write a program to check both the string are equal or not using string function.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
            char name1[10];
            char name2[10];
            clrscr();
            printf("Enter the name1= \n");
            scanf("%s",&name1);
            printf("Enter the name2= \n");
            scanf("%s",&name2);
            if(strcmp(name1,name2)==0)
            {
                        printf("Both the string are same");
            }
            else
            {
                        printf("Both the string are not same");
            }
            getch();
}
OUTPUT :
Run-1
Enter the name1 = Harsh
Enter the name2 = chauhan
Both the string are not same
Run-2
Enter the name1 = Harsh
Enter the name2 = Harsh
Both the string are same


PRACTICAL : 18.
AIM : Write a program to convert a string from lower case to upper case and upper case to lower case using string function.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
            char name1[10];
            char name2[10];
            clrscr();
            printf("Enter the name1= \n");
            scanf("%s",&name1);
            strlwr(name1);
            printf("\n\n Name1 is in lower case=%s",name1);
            strupr(name1);
            printf("\n\n Name1 is in upper case=%s",name1);
            getch();
}
OUTPUT :
Enter the name1 = Harsh
Name1 is in lower case = harsh
Name2 is in upper case = HARSH


PRACTICAL : 19.
AIM : Write a program to find the position of particular charcter from the string and display it's position using string function.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
            char name1[20]={"harsh"};
            char i,l,flag=0,position,ch;
            clrscr();
            printf("Enter the charcter to be shared= \n");
            scanf("%d",&ch);
            l=strlen(name1);
            for(i=0;i<l;i++)
            {
                        if(name1[i]==ch)
                        {
                                    position=i+1;
                                    flag=1;
                                    goto|b|;
                        }
            }
            |b|;
            if(flag==1)
            {
                        printf("position=%d",position);
            }
            else
            {
                        printf("Charcter not found");
            }
            getch();
}
OUTPUT :
Run-1
Enter chacter to be searched = a
position = 2
Run-2
Enter chacter to be searched = s
position = 4


PRACTICAL : 20.
AIM : Write a program to join two string and store it's value into third string.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
            char name1[20];
            char name2[20];
            clrscr();
            printf("Enter the Name1 = \n");
            scanf("%s",& name1);
            printf("Enter the Name2 = \n");
            scanf("%s",& name2);
            strcat(name1,name2);
            printf("\n\n name1=%s",name1);
            getch();
}
OUTPUT :
Enter the Name1 = Harsh
Enter the Name2 = Chauhan
Name1 = Harsh Chauhan


PRACTICAL : 21.
AIM : Write a program to display the address of variable and contect of variable using pointer variable.

#include<stdio.h>
#include<conio.h>
void main()
{
            int a;
            int *p;
            p=&a;
            clrscr();
            printf("Enter the value of A = \n");
            scanf("%d",& a);
            printf("\n\n Address of a = %d",p);
            printf("\n\n Address of p = %d",&p);
            printf("\n\n Value of a = %d",*p);
            getch();
}
OUTPUT :
Enter the value of a = 2001
Address of  a = -12
Address of p = -14
Value of a = 2001


PRACTICAL : 22.
AIM : Write a program to add all the element of array using pointer.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
            int *p;
            int a[5]={10,20,30,40,50};
            int i,sum=0;
            clrscr();
            p=&a[0];
            for(i=0;i<5;i++)
            {
                        sum=sum+*p;
                        p++;
            }
            printf("sum=%d",sum);
            getch();
}
OUTPUT :
Sum = 150


PRACTICAL : 23.
AIM : Write a program to find the length of the string using pointer.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
            char s[50]={"VPMP"};
            int count=0;
            char *cptr;
            clrscr();
            while(*cptr!='\0')
            {
                        count++;
                        cptr;
            }
            printf("length of string %s=%d \n",s,count);
            getch();
}
OUTPUT :
length of string VPMP = 4


PRACTICAL : 24.
AIM : Write a program to swap(interchange)  two number using user define function.

#include<stdio.h>
#include<conio.h>
void swap(int,int);
void main()
{
            int a,b;
            clrscr();
            printf("Enter the value of A=\n");
            scanf("%d",&a);
            printf("Enter the value of B=\n");
            scanf("%d",&b);
            swap(a,b);
            getch();
}
            void swap(int x,int y)
{
            int temp;
            temp=x;
            x=y;
            y=temp;
            printf("\n after interchange value of a=);
            printf("\n after interchange value of b=);

}
OUTPUT :
Enter the value of A=45
Enter the value of =54
after interchange value of a=54
after interchange value of b=45


PRACTICAL : 25.
AIM : Write a program to find the factorial of given number using user define function.

#include<stdio.h>
#include<conio.h>
long int factorial(long int);
void main()
{
            long int n,ans;
            int n,ans;
            clrscr();
            printf("Enter no :");
            scanf("%ld",&n);
            ans=factorial(n);
            printf("factorial is=%ld",ans);
            getch();
}
            long int factorial(long int m)
            {
                        int i;
                        long int f=1;
                        for(i=1;i<=n;i++)
                        {
                                    f=f*i;;
                        }
                        return(f);
}
OUTPUT :
Enter the no = 4
Factorial is = 24


PRACTICAL : 26.
AIM : Write a program to swap(interchange)  to  number using call by referance.

#include<stdio.h>
#include<conio.h>
void exchange(int *a,int *b);
void main()
{
            int x,y;
            clrscr();
            printf("Enter x=");
            scanf("%d",&x);
            printf("Enter y=");
            scanf("%d",&y);
            exchange(&x,&y);
            printf("x=%d",x);
            printf("y=%d",y);
            getch();
}
void exchange(int *a,int *b)
{
            int c;
            c=*a;
            *a=*b;
            *b=c;
}
OUTPUT :
Enter X = 10
Enrer Y = 20
X = 20
Y = 10


PRACTICAL : 27.
AIM : Write a program to find the factorial of given number using recursion.

#include<stdio.h>
#include<conio.h>
int factorial(int n);
void main()
{
            int n,fact;
            clrscr();
            printf("Enter no=");
            scanf("%d",&n);
            fact=factorial(n);
            printf("factorial of %d is %d",n,fact);
            getch();
}
int factorial(int n)
{
            int facto=1;
            if(n==1)
            {
                        return 1;
            }
            else
            {
                        facto=n*factorial(n-1);
            }
            return facto;
}
OUTPUT :
Enter no = 5
Factorial 5 is 120


PRACTICAL : 28.
AIM : Write a program to using Simple Macro.

#include<stdio.h>
#include<conio.h>
#define PI 3.14
void main()
{
            int r;
            float area;
            clrscr();
            printf("Enter the r=\n");
            scanf("%d",&r);
            area=pi*r*r;
            printf("area is %f",area);
            getch();
}
OUTPUT :
Enter r=2
Area = 12.560000


PRACTICAL : 29.
AIM : Write a program to find minimum number using Macro.

#include<stdio.h>
#include<conio.h>
#define MIN(a,b)(a<b)
void main()
{
            int a,b;
            clrscr();
            printf("enter the value of A =\n");
            scanf("%d",&a);
            printf("enter the value of B =\n");
            scanf("%d",&b);
            if(MIN(a,b))
            {
                        printf(" A is Minimum");
            }
            else
            {
                        printf(" B is Minimum");
            }          
            getch();
}
OUTPUT :
Enter the A = 20
Enter the B = 10
B is minimum


PRACTICAL : 30.
AIM : Create a structure student which contains student information.

#include<stdio.h>
#include<conio.h>
struct student
{
            char name[50];
            int e_no;
            int mark;
            char branch;
            char sem;
};
            void main()
{
            struct student s1;
            clrscr();
            printf("Enter the student name= \n");
            gets(s1.name);
            printf("Enter the student Enrollment no= \n");
            scanf("%d",&s1.e_no);
            printf("Enter the student Mark= \n");
            scanf("%d",&s1.mark);
            printf("Enter the student Branch= \n");
            scanf("%s",&s1.branch);
            printf("Enter the student sem= \n");
            scanf("%s",&s1.sem);
            printf("\n Student Information \n");
            printf("\n name=%s",s1.stud_name);
            printf("\n e_no=%d",s1.stud_no);
            printf("\n mark=%d",s1.mark);
            printf("\n Branch=%S",s1.branch);
            printf("\n Sem=%s",s1.sem);
            getch();
}
OUTPUT :
Enter the Name = Harsh
Enter the e_no = 525
Enter the Mark = 111
Enter the Branch = C.E.
Enter the Sem = 2nd
STUDENT INFORMATION
Name = Harsh
Enrollment No = 525
Mark = 111
Branch = C.E.
Sem = 2nd


PRACTICAL : 31.
AIM : Create a structure student which contains member like stud_name , stud_no ,mark1 , mark2 , totalmarks.
Write aprogram to store and display the value of structure member.

#include<stdio.h>
#include<conio.h>
struct student
{
            char stud_name[50];
            int stud_no;
            int mark1;
            int mark2;
            int totalmark;
};
            void main()
{
            struct student s1;
            clrscr();
            printf("Enter the student name= \n");
            gets(s1.stud_name);
            printf("Enter the student Enrollment no= \n");
            scanf("%d",&s1.stud_no);
            printf("Enter the student Mark1= \n");
            scanf("%d",&s1.mark1);
            printf("Enter the student Mark2= \n");
            scanf("%d",&s1.mark2);
            s1.totalmark=s1.mark1+s1.mark2;
            printf("\n Student Information \n");
            printf("\n stud_name=%s",s1.stud_name);
            printf("\n stud_no=%d",s1.stud_no);
            printf("\n mark1=%d",s1.mark1);
            printf("\n mark2=%d",s1.mark2);
            printf("\n totalmark=%d",s1.totalmark);
            getch();
}
OUTPUT :
Enter the Student Name = Harsh
Enter the Student Enro.no = 525
Enter the Mark1 = 20
Enter the Mark2 = 24
STUDENT INFORMATION
Stud_Name = Harsh
Stud_No = 525
Mark1 = 20
Mark2 = 24
Totalmarks = 44


PRACTICAL : 32.
AIM : Create a structure student which contains student information.Write aprogram to store and display the information of 5 students.
#include<stdio.h>
#include<conio.h>
struct student
{
            char stud_name[50];
            int stud_no;
            int mark1;
            int mark2;
            int totalmark;
};
            void main()
{
            struct student s1;
            clrscr();
            for(i=0;i<5;i++)
            {
                        printf("Enter the student name= \n");
                        gets(s1.stud_name);
                        printf("Enter the student Enrollment no= \n");
                        scanf("%d",&s1.stud_no);
                        printf("Enter the student Mark1= \n");
                        scanf("%d",&s1.mark1);
                        printf("Enter the student Mark2= \n");
                        scanf("%d",&s1.mark2);
            }
            printf("\n Student Information \n");
            for(i=0;i<5;i++)
            {
                        printf("\n stud_name=%s",s1.stud_name);
                        printf("\n stud_no=%d",s1.stud_no);
                        printf("\n mark1=%d",s1.mark1);
                        printf("\n mark2=%d",s1.mark2);                   
                        s1.totalmark=s1.mark1+s1.mark2;
                        printf("\n totalmark=%d",s1.totalmark);
                        printf("\n");
}
OUTPUT :
Enter the Student Name = Harsh
Enter the Student Enro.no = 525
Enter the Mark1 = 20
Enter the Mark2 = 24

Enter the Student Name = Nimesh
Enter the Student Enro.no = 526
Enter the Mark1 = 12
Enter the Mark2 = 20

Enter the Student Name = Arun
Enter the Student Enro.no = 523
Enter the Mark1 = 23
Enter the Mark2 = 21

Enter the Student Name = Shankar
Enter the Student Enro.no = 533
Enter the Mark1 = 19
Enter the Mark2 = 22

Enter the Student Name = Rahul
Enter the Student Enro.no = 527
Enter the Mark1 = 11
Enter the Mark2 = 13

STUDENT INFORMATION

Stud_Name = Harsh
Stud_No = 525
Mark1 = 20
Mark2 = 24
Totalmarks = 44

Stud_Name = Nimesh
Stud_No = 526
Mark1 = 12
Mark2 = 20
Totalmarks = 32

Stud_Name = Arun
Stud_No = 523
Mark1 = 23
Mark2 = 21
Totalmarks = 44

Stud_Name = Shankar
Stud_No = 533
Mark1 = 19
Mark2 = 22
Totalmarks = 41

Stud_Name = Rahul
Stud_No = 527
Mark1 = 11
Mark2 = 13
Totalmarks = 24


PRACTICAL : 33.
AIM : Write a program to using Pointer to structure.

#include<stdio.h>
#include<conio.h>
struct student
{
            int roll;
            char name[50];
};
void main()
{
            struct student *p;
            printf("Enter roll number:");
            scanf("%d",&(*p).roll);
            printf("Enter name:");
            scanf("%s",&(*p).name);
            printf("\n Student Information \n");
            printf("Roll number=%d",p->roll);
            printf("\n Name=%s",p->name);
            getch();
}
OUTPUT :
Enter the Roll no = 525
Enter the Name = Harsh V Chauhan
STUDENT INFORMATION
Roll No. = 525
Name = Harsh

PRACTICAL : 34.
AIM : Write a program to which demonstrate the use of typedef data type.
#include<stdio.h>
#include<conio.h>
Void main()
{
            typedef int harsh;
            harsh a,b,sum;
            clrscr();
            printf(“Enter the A : ”);
            scanf(“%d”,&a);
            printf(“Enter the B : ”);
            scanf(“%d”,&b);
            sm=a+b;
            printf(“Sum=%d”,sum);
            getch();
}
OUTPUT :
A : 10
B : 10
Sum=20

PRACTICAL : 35.
AIM : Write a program to which demonstrate the use of enumerated  data type.

#include<stdio.h>
#include<conio.h>
Void main()
{
            enum days{mon,tues,wed,thurs,fri,satur,sun};
            clrscr();
            printf(“Monday=%d”,mon);
            printf(“Sunday=%d\n”,sun);
            printf(“\n Thursday=%d”,thurs);
            getch();
}
OUTPUT :
Monday=0
Sunday=14
Thursday=11


PRACTICAL : 36.
AIM : Write a program to using UNION.

#include<stdio.h>
#include<conio.h>
union student
{
            char name[50];
            int e_no;
            int mark;
            char branch;
            char sem;
};
            void main()
{
            union student s1;
            clrscr();
            printf("Enter the student name= \n");
            gets(s1.name);
            printf("Enter the student Enrollment no= \n");
            scanf("%d",&s1.e_no);
            printf("Enter the student Mark= \n");
            scanf("%d",&s1.mark);
            printf("Enter the student Branch= \n");
            scanf("%s",&s1.branch);
            printf("Enter the student sem= \n");
            scanf("%s",&s1.sem);
            printf("\n Student Information \n");
            printf("\n name=%s",s1.stud_name);
            printf("\n e_no=%d",s1.stud_no);
            printf("\n mark=%d",s1.mark);
            printf("\n Branch=%S",s1.branch);
            printf("\n Sem=%s",s1.sem);
            getch();
}
OUTPUT :
Enter the Name = Harsh
Enter the e_no = 525
Enter the Mark = 111
Enter the Branch = C.E.
Enter the Sem = 2nd


PRACTICAL : 37.
AIM : Write a program to create a Data file.

#include<stdio.h>
#include<conio.h>
Void main()
{
            int no;
            char name[20];
            FILE *ptr;
            Clrscr();
            ptr=fopen(“Harsh.doc”,”w”);
            getch();
}
OUTPUT :
Desktop in automatically created to Harsh naming WORD file.

PRACTICAL : 38.
AIM : Write a program to write the data to data file.

#include<stdio.h>
#include<conio.h>
Void main()
{
FILE *ptr;
char name1[20];
int no1;
Clrscr();
            ptr=fopen(“abc.txt”,”r”);
fscanf(ptr,”%d  %s”,&no1,name1);
            printf(“No1=%d”,no1);
            printf(“\n Name1=%s”,name1);
getch();
}
OUTPUT :
Desktop in automatically created to “abc” naming WORD file and automatically write to
No1=
Name1=


PRACTICAL : 39.
AIM : Write a program to read a data from the data file .

#include<stdio.h>
#include<conio.h>
Void main()
{
FILE *ptr;
char name[20]={“vpmp”};
char name1[20];
int no;
int no1;
Clrscr();
ptr=fopen(“abc.txt”,”w”);
no=525;
fprintf(ptr,“%d  %s”,no,name);
fclose(ptr);
            ptr=fopen(“abc.txt”,”r”);
fscanf(ptr,”%d  %s”,&no1,&name1);
            printf(“No1=%d”,no1);
            printf(“\n Name1=%s”,name1);
getch();
}
OUTPUT :
Desktop in automatically created to “abc” naming WORD file and automatically write to
No1 = 525
Name1 = vpmp
After opening read purpose only-


PRACTICAL : 40.
AIM : Write a program to write and read a data file .

#include<stdio.h>
#include<conio.h>
Void main()
{
char name[20];
char name1[20];
int no;
int no1;
FILE *fp;
Clrscr();
fp=fopen(“xyz.txt”,”w”);
no=525;
gets(name);
fprintf(fp,“%d \n %s”,no,name);
fclose(fp);
            fp=fopen(“xyz.txt”,”r”);
fscanf(fp,”%d  %s”,&no1,&name1);
fclose(fp);
printf(“No1=%d \n”,no1);
            printf(“\n Name1=%s”,name1);
            getch();
}
OUTPUT :
Desktop in automatically created to “xyz” naming WORD file and automatically write to
No1 = 525
Name1 =
After opening read purpose only-


PRACTICAL : 41.
AIM : Write a program to write and read a data file using getc() and putc() function .
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
Void main()
{
FILE *fp;
char c,ch
            clrscr();
            fp=fopen(“vpmp.txt”,”w”);
            printf(“Enter the Charcter=\n”);
            scanf(“%c”,ch);
            putc(ch,fp);
fclose(fp);
fp=fopen(“vpmp.txt”,”r”);
c=getc(fp);
printf(“%c”,c);
getch();
}
OUTPUT :
Desktop in automatically created to “vpmp” naming WORD file and automatically write to
Enter the Charcter = Harsh
Harsh
After opening read purpose only-



PRACTICAL : 42.
AIM : Write a program to update the content of file using fseek() function .

#include<stdio.h>
#include<conio.h>
Void main()
{
FILE *fp;
            fp=fopen(“abc.txt”,”w”);
            fprintf(fp,“VPMP POLYTECHNIC”);
            fprintf(fp,“ATUL”);
            printf(“FILE IS UPDATED”);
getch();
}
OUTPUT :
ATUL POLYTECHNIC
FILE IS UPDATED


PRACTICAL : 43.
AIM : Write a program to read 10 array elements and store the odd elements into file named”Oddfile” and Even elements into file named”Evenfile” and display the content of both file.

#include<stdio.h>
#include<conio.h>
Void main()
{
int i,a[10];
            int j,k,no,even[10],odd[10];
            clrscr();
            printf(“Enter the Array Elements=\n”);
            for(i=0;i<10;i++)
            {
                        scanf("%d \n",&a[i]);
            }
            for(i=0;i<10;i++)
            {
                        if(a[i]%2==0)
                        {
                                    FILE *fpeven;
fopen=fopen(“evenfile.txt”,”a”);]
                        fprintf(fopen,“%d”,a[i]);
                        fclose(fpeven);
            }
            else
            {
                                    FILE *fpodd;
fopen=fopen(“oddfile.txt”,”a”);]
                        fprintf(odd,“%d”,a[i]);
                        fclose(fpodd);
                        k++;
            }
            printf(“Content of Odd File”);
                        FILE *fp;
fp=fopen(“oddfile.txt”,”r”);]
                        for(i=0;i<k;i++)
                        {
                        fscanf(fp,”%d”,&no);
                        printf(“%d”,no);
            }
            fclose(fp);
                        for(i=0;i<j;i++)
                        {
                        fscanf(fp,”%d”,&no);
                        printf(“%d”,no);
            }
            printf(“Content of Even File”);
                        FILE *fp;
fp=fopen(“evenfile.txt”,”r”);]
                        for(i=0;i<k;i++)
                        {
                        fscanf(fp,”%d”,&no);
                        printf(“%d”,no);
            }
            fclose(fp);
                        for(i=0;i<j;i++)
                        {
                        fscanf(fp,”%d”,&no);
                        printf(“%d”,no);
            }
            no=getw(fp);
            fclose(fp);
                        getch();
}
OUTPUT :
Enter the Array Elements =
1
2
3
4
5
6
7
8
9
10
Content of Even file =
2
4
6
8
10
Content of Odd file =
1
3
5
7
9

PRACTICAL : 44.
AIM : Write a program to read 5 values using Command line arguments .

#include<stdio.h>
#include<conio.h>
Void main(int argc,char *argv[)
{
int i;
clrscr();
for(i=0;i<argc;i++)
{
            Printf(“%d is %s”,i+1,argv[i]);
                        Printf(“\n”);
            }
            getch();
}
OUTPUT :
1 is c:\>
2 is A.C.P.
3 is Maths-2.
4 is B.phy.
5 is C.P.D.
6 is BE.

PRACTICAL : 45.
AIM : Write a program to add 5 values using Command line arguments .

#include<stdio.h>
#include<conio.h>
Void main(int argc,char *argv[)
{
int I,sum=0;
clrscr();
for(i=0;i<argc;i++)
{
            Sum=sum+atoi(argv[i]);
}
Printf(“sum=%d”,sum);
getch();
}
OUTPUT :
C:\TC\Bin\cmdsum  1  2  3  4  5  6
Sum = 15

sdf

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © 2013 Computer Guru : Comzguru Hack - Shingeki No Kyojin - Powered by Blogger - Designed by Johanes Djogan -