Saturday, 5 December 2015

Copy the Data or Content of One file to Another file Using C Program.


Copy the Data or Content of One file to Another file Using C Program


Program Code for Copy File

#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
FILE *fp2;
char c;
fp=fopen("Myfile.txt","r");
fp2=fopen("MyNewFile.txt","w");
c=getc(fp);
while(c!=EOF)
{
fprintf(fp2,"%c",c);
c=getc(fp);
}
fclose(fp);
}

File Handling Programs In C Language

File Management Using C

Prepared By Hitesh Vataliya


One of the difficult work for any one to access the notepad or word file using the c program. But Dennis Ritchie makes it possible for us with the help of fopen() function which is used for connection between our c program and file.
There are many builtin functions for file management in c programming language. Some of them are as below.
fopen() - used to connect with the file, for creating the file or opening the file which was already                        created by using the mode we can open it for 
               r   = reading 
               w = writing
               a  = appending
fclose() - closing the connection with the file after our work is completed.
getc()    - get one character from the file.
putc()    - print one character into the file.
getw()   - get one integer number from the file.
putw()   - Print one integer number into the file.
fscanf() - Scans or take as input one line or string or integer from the file.
fprintf() - Print one line or string or integer to the file.
fseek()   - move the file pointer into the file from begin, current position or end of the file as many                       steps we wants to move the file pointer.
                0 = beginning 
                1 = current position 
                0 = end of the file
 rewind() - move the file pointer to the beginning of the file or 0 th position into the given file.
ftell()     -  returns the position of the file pointer into the given file.

FILE is used for creating file pointer, it acts as a type.


Program 1. Write a program for create a file and insert 3 lines of text into the file.


#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
fp=fopen("Myfile.txt","w");
fprintf(fp,"Welcome to the VATALIYA TUITION CLASSES\n");
fprintf(fp,"FILE IS CREATED BY HITESH VATALIYA\n");
fprintf(fp,"TODAY IS 4TH DEC,2015");
fclose(fp);
}


Program 2. Write a program for reading a text file which was already created.


#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
char c;
fp=fopen("Myfile.txt","r");
c=getc(fp);
while(c!=EOF)
{
printf("%c",c);
c=getc(fp);
}
fclose(fp);
}
          

Thursday, 3 December 2015

Computer Training Center Baroda For Live Project Training, Subject Training and Programming Language Training

One of the Computer Training Center in Vadodara, Gujarat, India. Which offers Main Three Services as given below.
(i) Live Project Training (ASP.NET, PHP, JAVA, ADV JAVA, ADV ASP.NET, VB.NET, WEB DESIGN, Android, IPhone, Web Development, SEO, JOOMLA, DRUPAL, WPF)
(ii) Programming Training (C , C++, C#, VB, Perl, Python, Java, JavaScript, VB Script, ASP Script)
(iii) Subject Training (Oracle, OS, CN, Adv CN, DS, Algorithms, MS SQL Server, MySQL, DBMS, IWA, HTML, CSS, MP, MC, SP)
                

             All the above services is offered to all the students of GTU (Diploma, BE, ME, BCA, MCA in Computer Engineering or Computer Science and Engineering or Information Technology), MSU(Diploma, BE, ME, BCA, MCA in Computer Engineering or Computer Science and Engineering or Information Technology), IGNOU(Indira Gandhi National Open University), MGU(Mahatma Gandhi University), SMU(Sikkim Manipal University), SNDT(Shreemati Nathibai Damodar Thackersey),NIELIT-National Institute of Electronics and Information Technology, SPU (Sardar Patel University).

COMPUTER ENGINEERING 4TH SEM SUBJECT TRAINING CLASSES IN VADODARA
Below are the list of the subjects on which we are giving training:
140701 - MicroProcessor and Interfacing
140702 - Operating Systems
140703 - Object Oriented Analysis and Design and UML
140704 - Object Oriented Concepts and Programming
140705 - Object Oriented Programming With C++

One of The Best Degree Engineering Classes in Vadodara.
Computer Engineering Subject Training Offered @ VTC Vadodara.
Visit Our Center : www.vataliyatuitionclasses.com

List of the courses offered for Sixth Semester Bachelor of Engineering in Computer Science and Engineering.
160701 - Software Engineering
160702 - Information Security
160703 - Computer Graphics
160705 - Web Application Development

160706 - System Programming

Final Year Project Training Providers in Vadodara for Diploma, BE, ME, BCA and MCA.

Asp.net Project Training in Vadodara

Project Overview,
HTML,
CSS,
JAVASCRIPT,
ASP.NET NAVIGATION CONTROLS,
VALIDATION CONTROLS,
STATE MANAGEMENT TECHNIQUES,
AJAX,
MS SQL SERVER,
ADO.NET,
ONE TIER ARCHITECTURE,
TWO TIER ARCHITECTURE,
THREE TIER ARCHITECTURE,
ASP.NET DATA CONTROLS
LINQ,
WEB SERVICES,
WPF/WCF/WWF,
REPORT.



If You wants to learn Programming Language/ Subject For BCA, MCA, Diploma, Degree Engineering (BE), ME, Then Visit : VATALIYA TUITION CLASSES.


FINAL YEAR PROJECT TRAINING


PHP PROJECT TRAINING


JAVA PROJECT TRAINING 


ASP.NET PROJECT TRAINING


IGNOU BCA/MCA


NIELIT O LEVEL/A LEVEL/B LEVEL/C LEVEL


GTU DIPLOMA/BE/ME IN COMPUTERS/IT

Important Programs of C Language

1. Write a program in 'C' to convert a given complete string to upper case.


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char name[30]="Vataliya Tuition Classes";
int i,len;
clrscr();
len=strlen(name);
for(i=0;i<len;i++)
{
if(name[i]>=97&&name[i]<=122)
{
name[i]=name[i]-32;
}
}
printf("%s",name);
getch();
}

2. Write a program in 'C' to calculate the sum of the corresponding elements of two arrays of integers of same size. 

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],b[5],*p;
int i;
clrscr();
printf("\n\n\t\tArray A\n\n\t\t");
for(i=0;i<5;i++)
{
printf("Enter element : ");
scanf("%d",&a[i]);
}
printf("\n\n\t\tArray B\n\n\t\t");
for(i=0;i<5;i++)
{
printf("Enter element : ");
scanf("%d",&b[i]);
}
for(i=0;i<5;i++)
{
*(p+i)=a[i]+b[i];
}
printf("\n\n\t\tOUTPUT\n\n");
for(i=0;i<5;i++)
{
printf("\n\t\t%d",*(p+i));
}

getch();

}


3. Write a program for use of gets() and puts().


#include<stdio.h>
#include<conio.h>
void main()
{
char name[50];
clrscr();
printf("Enter Name : ");
gets(name);  
//gets is used for input string or char array from the user
printf("\n\nYou are ");
puts(name);  
// puts is used to print string on the screen
getch();

}


4. Write a Program in C Programming Language for Multiplication and Addition of 3x3 matrices.


#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3];
int i,j,k;
clrscr();
printf("\nEnter Array A\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("Enter a[%d][%d]",i,j);
scanf("%d",&a[i][j]);
}
}
printf("\nEnter Array B\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("Enter b[%d][%d]",i,j);
scanf("%d",&b[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=0;
for(k=0;k<3;k++)
{
c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
}
}
}
printf("\n\nArray C\n");
for(i=0;i<3;i++)
{       printf("\n");
for(j=0;j<3;j++)
{
printf("\t%d",c[i][j]);
}
}
//Addition of 3x3 matrices
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf("\n\nArray C\n");
for(i=0;i<3;i++)
{       printf("\n");
for(j=0;j<3;j++)
{
printf("\t%d",c[i][j]);
}
}
getch();

}

If You wants to learn C Programming Language For BCA, MCA, Diploma, Degree Engineering (BE), ME, Then Visit : VATALIYA TUITION CLASSES.


FINAL YEAR PROJECT TRAINING


PHP PROJECT TRAINING


JAVA PROJECT TRAINING 


ASP.NET PROJECT TRAINING


IGNOU BCA/MCA


NIELIT O LEVEL/A LEVEL/B LEVEL/C LEVEL


GTU DIPLOMA/BE/ME IN COMPUTERS/IT










Pointer in C Programming

Pointer in C Programming Language

Prepared By : Hitesh Vataliya

Pointer is a reference variable which stores address of another variable inside it.
Pointer variable occupies only 2 bytes of memory for storing address of any type of variable like int, char, float or double. Because pointer variable only stores address of same type of data which the pointer variable have, and for storing address it only needs two bytes of memory.
Pointer is flexible to use with character array as well as we can access multidimensional array with pointer variable easily which is called array of pointers.

Here 1 example is given
 int a =10;
int *p;
p=&a;

in above example a is int type variable which stores 10 inside it.
*p is pointer variable.
p stores address of int type variable a.
*p having the value of a.

Programming Exercises of Pointer 


1. Write a program to show the use of pointer[ change the content stored inside variable a using pointer p].


void main()
{
int a=10;
int *p;
clrscr();
p=&a;
printf("\n\t\tThe value of a is %d and address is %d",a,&a);
printf("\n\t\tThe value of *p is %d and p is %d",*p,p);
*p=20;
printf("\n\t\tThe value of a is %d and address is %d",a,&a);
printf("\n\t\tThe value of *p is %d and p is %d",*p,p);
getch();
}

Output : The value of a will be changed to 20 instead of 10 at the end of the program with pointer variable p.



2. Write a program for swap two variables value using call by reference. [use pointer variables as parameter]


#include<stdio.h>
#include<conio.h>
void swap(int *n1,int *n2)
{
int *temp;
*temp=*n1;
*n1=*n2;
*n2=*temp;
}
void main()
{
int a=10;
int b=111;
clrscr();
printf("\n\t\tThe value of a is %d and b is %d",a,b);
swap(&a,&b); //call by reference
printf("\n\t\tThe value of a is %d and b is %d",a,b);
getch();
}


Output : swap function changes the values of a and b return to the main function, we can get two values return into the main function from called function with the help of pointers only.


3. Write a program to access character array using pointer.

Scale Factor is the difference of memory address from going one memory address to another inside the array. Here the array is of character type and hence it's Scale Factor is 1.

#include<stdio.h>
#include<conio.h>
void main()
{
char name[30]="Vataliya Tuition Classes";
char *p;
int i;
clrscr();
p=&name[0];
for(i=0;i<strlen(name);i++)
{
printf("%c",*p);
p++;
}
getch();
}

Output : Here the Scale Factor is 1. If The array type is float then Scale Factor will be 4.

If You wants to learn C Programming Language For BCA, MCA, Diploma, Degree Engineering (BE), ME, Then Visit : VATALIYA TUITION CLASSES.

FINAL YEAR PROJECT TRAINING

PHP PROJECT TRAINING

JAVA PROJECT TRAINING 

ASP.NET PROJECT TRAINING

IGNOU BCA/MCA

NIELIT O LEVEL/A LEVEL/B LEVEL/C LEVEL

GTU DIPLOMA/BE/ME IN COMPUTERS/IT

Tuesday, 1 December 2015

Concepts of Structure in C Language

Structure in C Programming Language

Created By Hitesh Vataliya

Structure is collection elements having different datatypes. Such as Student structure having rollno, percentage, name.
Structure is created with the help of struct keyword before name of structure tag.
rollno is int type,percentage is declared with float type,name of student is declared with char array type.
All three are known as elements of the structure.
Example,
           struct student
          {
                int rollno;
               float percentage;
               char name[30];
          };
student is name of structure which is known as structure tag, student is used to create element or variable of the structure.
rollno, percentage and name are not themselves as a variable. We can access them by the use of variable student type here in below example s1 and s2.


1. Write a program to create structure student.

#include<stdio.h>
#include<conio.h>
struct stud
{
int rollno;
float perc;
        char name[30];
}s1;
void main()
{
struct stud s2;
clrscr();
printf("Enter rollno of student1 : ");
scanf("%d",&s1.rollno);
printf("Enter rollno of student2 : ");
scanf("%d",&s2.rollno);
printf("Enter Percentage of student1 : ");
scanf("%f",&s1.perc);
printf("Enter Percentage of student2 : ");
scanf("%f",&s2.perc);
        printf("Enter name of student1 : ");
scanf("%d",s1.name);
        printf("Enter name of student2 : ");
scanf("%d",s2.name);
printf("\n\n\tRollno\t\tPercentage\tName\n");
printf("\n-------------------------------------");
printf("\n\t%d\t\t%f\t%s",s1.rollno,s1.perc,s1.name);
printf("\n\t%d\t\t%f\t%s",s2.rollno,s2.perc,s2.name);
getch();
}



2. Write a program to create structure for orders of computer having orderno, price, quantity as input and generate tax amount and total amount as an output.

#include<stdio.h>
#include<conio.h>
struct computer
{
    int orderno;
int qty;
int price;
float tax;
float total;
};
void main()
{
int i;
struct computer c[10];
clrscr();
for(i=0;i<3;i++)
{
printf("Enter order no : ");
scanf("%d",&c[i].orderno);
printf("How many computers ? ");
scanf("%d",&c[i].qty);
printf("Price of each computer : ");
scanf("%d",&c[i].price);
c[i].tax=(0.14*c[i].qty*c[i].price);
c[i].total=((float)c[i].qty*c[i].price)+c[i].tax;
}
printf("\n\n\tOrderno\tQuantity\tPrice\ttax\t\tTotal Amount\n");
printf("\n--------------------------------------------------------------------------");
for(i=0;i<3;i++)
{
printf("\n\t%d\t%d\t\t%d\t%f\t\t%f",c[i].orderno,c[i].qty,c[i].price,c[i].tax,c[i].total);
}
getch();
}


3. Write a program to use function with structure.

#include<stdio.h>
#include<conio.h>
struct employee
{
int empno;
char name[50];
int salary;
};
void printemp(struct employee a[],int s)
{
int i;
printf("\n\n\tEmployeeNo\tName\tSalary\n");
printf("\n-----------------------------------------------");
for(i=0;i<s;i++)
{
printf("\n\t%d\t\t%s\t%d",a[i].empno,a[i].name,a[i].salary);
}
}
void main()
{
int i,size=3;
struct employee e[70];
clrscr();
for(i=0;i<size;i++)
{
printf("Enter employeee no : ");
scanf("%d",&e[i].empno);
printf("Enter name of employee : ");
scanf("%s",&e[i].name);
printf("Enter salary of employee : ");
scanf("%d",&e[i].salary);
}
printemp(e,size);//call of function
getch();
}