Thursday, 3 December 2015

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










No comments:

Post a Comment