## Pages

### Sum of Array using Pointers

This program adds all the elements of array and print the sum and average of it using pointers and function. This is a part of Mumbai University MCA Colleges C program MCA Sem 1

#include<stdio.h>
#include<conio.h>
void main()
{
int a,n,i,j;
clrscr();
printf("Enter no of elements you want to enter in array");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
getch();
}
void add(int *x , int y)
{
int i,sum=0;
float avg=0;
for(i=0;i<y;i++)
{
sum+=*(x+i);

}
avg=sum/y;
printf("\nSum of array= %d",sum);
printf("\nAverage of array elements = %f",avg);
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Swapping using pointer C program

This Program swaps 2 numbers using pointers and functions . This is a part of  Mumbai University MCA Colleges C Program MCA sem 1

#include<stdio.h>
#include<conio.h>
void swap(int*, int *);
void main()
{
int a,b;
clrscr();
printf("Enter 2 nos\n");
scanf("%d %d",&a, &b);
printf("\nBefore swapping: %d %d",a,b);
swap(&a, &b);
printf("\n After swaping: %d %d",a,b);
getch();
}
void swap(int *x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Addition of Arrays C program

This C program accepts a 2-dim array of size 4*4 and prints the addition of all elements in individual columns. And print the result as below:
p q r s
p q r s
p q r s
p q r s
4p 4q 4r 4s
This is a part of Mumbai University MCA Colleges C programs MCA Sem 1

#include<stdio.h>
#include<conio.h>
void main()
{
int a,i,j,s={0,0,0,0};
clrscr();
printf("\nEnter values for 2D array\n");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{scanf("%d",&a[i][j]);}
}
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
printf("%d ",a[i][j]);
s[j]=s[j]+a[i][j];
}
printf("\n");
}
printf("-------------------\n");
for(j=0;j<4;j++)
{
printf("%d ",s[j]);
}
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### String Pointers C program

This program finds string length, copy a string and compare two strings using Pointers and Functions. This is a part of Mumbai University MCA Colleges C Programs MCA Sem 1

#include<stdio.h>
#include<conio.h>
int xstrlen(char *);
void xstrcopy(char *, char *);
int xstrcomp(char *, char *);
void xstrconcat(char *);
void main()
{
char s1,s2;
int i,ch;
clrscr();
printf("\n 1.String Length \n 2.String Copy \n 3.String Compare \n 4. Concatenation of 2 Strings \n Enter your choice");
scanf("%d",&ch);
switch(ch)
{
case 1:
{
int l=0;
printf("\nEnter String");
scanf("%s",&s1);
l=xstrlen(s1);
printf("\n Length of %s is %d",s1,l);
break;
}
case 2:
{
printf("\n Enter 1st string");
scanf("%s",&s1);
printf("\n Enter 2nd string");
scanf("%s",&s2);
xstrcopy(s1,s2);
printf("\n First string: %s",s1);
break;
}
case 3:
{
int a;
printf("\n Enter 1st string");
scanf("%s",&s1);
printf("\n Enter 2nd string");
scanf("%s",&s2);
a=xstrcomp(s1,s2);
if(a==0)
printf("Strings are equal");
else
printf("Strings are not equal");
break;
}
case 4:
{
printf("\n Enter 1st string");
scanf("%s",&s1);
printf("\n Enter 2nd string");
scanf("%s",&s2);
xstrconcat(s1,s2);
printf(“String after concatenation: %s”, s1);
}
default:
{
break;
}
}
getch();
}
int xstrlen(char *s)
{
int l=0;
while(*s!='\0')
{
l++;
s++;
}
return(l);
}
void xstrcopy(char *s1, char *s2)
{
while(*s2!='\0')
{
*s1=*s2;
s1++;
s2++;
}
*s1='\0';
}
int xstrcomp(char *s1, char *s2)
{
while(*s1!='\0' && *s2!='\0')
{
if(*s1==*s2)
return(0);
s1++;
s2++;
}
return(*s1-*s2);

}
void xstrconcat(char *s1, char *s2)
{
int i=0, len=0;
while(*(s1+i)!=’\0’)
{
len++;
i++;
}
for(i=len;*s2==’\0’;++i)
{
*(s1+i)=*s2;
s2++;
}
*(s1+i)=’\0’;
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### String (Concat, Reverse, Copy, Length) without Built in Functions C program

This Program performs different string options such as length of string, Concatenation of Strings, Reverse and Copy with out built in functions. This is a part of Mumbai University MCA Colleges C Program MCA Sem 1

#include<stdio.h>
#include<conio.h>
void main()
{
char arr,s1,s2,s3;
int opt,i=0,j,len=0;
clrscr();
printf("Enter any option\n\n");
printf("1: Find out length of the string\n");
printf("2: Concatenate of the two string\n");
printf("3:Reverse of the string\n");
printf("4:Copy of the string\n");
printf("Enter the choice\n\n\n\n\n");
scanf("%d",&opt);
switch(opt)
{
case 1:
{
printf("Enter any string \n");
scanf("%s",arr);
for(i=0;arr[i]!='\0';i++);
printf("The length of the string %d",i);
break;
}
case 2:
{
printf(" String Concatenation \n");
printf("\nEnter the First string:\n");
scanf("%s", s1);
printf("\nEnter Second string");
scanf("%s",s2);
for(i=0;s1[i]!='\0';i++)
{
s3[i]=s1[i];
}
s3[i]='\0';
for(j=0;j<=i;j++)
{
s3[i+j]=s2[j];
}
printf("The Concatenated string is %s",s3);
break;
case 3:
{
printf(" Reverse the string ");
printf("\nEnter the string");
scanf("%s",s1);
while(s1[i]!='\0')
{
len=len+1;
i++ ;
}
for(i=len-1;i>=0;i--)
{
printf("%c",s1[i]);
}
break;
}
case 4:
{
printf(" String copying \n");
printf("Enter 1st string :");
scanf("%s",s1);
printf("Enter 2st string :");
scanf("%s",s2);
while(s2[i]!='\0')
{
s1[i]=s2[i];
i++;
}
s1[i]='\0';
printf("%s",s1);
break;
}
default:
{
printf("Not is valid Option........");
}
}
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Fibonacci series Recursion C program

This program displays the Fibonacci series using recursion. Accept the end value of that series from user. This is a part of Mumbai University MCA Colleges C Program MCA Sem 1

#include<stdio.h>
#include<conio.h>
int f=1,s=1,t=0;
void main()
{
int n;
clrscr();
printf("Enter No.");
scanf("%d",&n);
printf("fibonacci series is:\n%d %d ",f,s);
fib(n);
getch();
}
int fib(int x)
{
t=f+s;
f=s;
s=t;
printf("%d ",t);
if(t<x)
fib(x);
else
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Fibonacci series C program

This program is to display the Fibonacci series. Accept the end value of that series from user. This is a part of Mumbai University MCA Colleges C Programs MCA Sem 1

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n;
clrscr();
printf("Enter No.");
scanf("%d",&n);
fib(n);
getch();
}
int fib(int x)
{
int f=1,s=1,t=0;
printf("fibonacci series is:\n%d %d ",f,s);
while(t<x)
{
t=f+s;
f=s;
s=t;
printf("%d ",t);
}
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Sorting of Array Descending C programs

This program sorts an array in descending order using functions. This is a part of Mumbai University MCA Colleges C Programming MCA Sem 1

#include<conio.h>
#include<stdio.h>
void main()
{
int ar,sz,i;
void srt(int a,int);
clrscr();
printf("\n Enter size of array: ");
scanf("%d",&sz);
printf("\n Enter %d elements: ",sz);
for(i=0;i<sz;i++)
{
scanf("%d",&ar[i]);
}
srt(ar,sz);
getch();
}
void srt(int ar[],int sz)
{
int l,m;
for(l=0;l<sz;l++)
for(m=0;m<sz-1;m++)
{
if(ar[m]<ar[m+1])
{
ar[m]=ar[m]+ar[m+1];
ar[m+1]=ar[m]-ar[m+1];
ar[m]=ar[m]-ar[m+1];
}
}
printf("\n Descending order: ");
for(l=0;l<sz;l++)
{
printf("\n %d ",ar[l]);
}
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Even number Without IF, For loop

This program to print all the even numbers Upto an Upper-Limit entered by the user.Use functions to print the above series of number. Without using 'if'. This is a part of Mumbai University MCA Colleges C Programs MCA Sem 1

#include<stdio.h>
#include<conio.h>
int calceven(int);
void main()
{
int j;
clrscr();
printf("Enter the limit:");
scanf("%d",&j);
printf(""The Even Numbers:");
calceven(j);
getch();
}
int calceven(int j)
{
int i;
for(i=2;i<=j;i+=2)
{
printf("%d\n",i);
}
return(i);
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Largest Number in 2D array / Matrix C program

Write a program accepts 25 numbers from user & stored in two dimensional array of size 5*5 and find the largest number amongst these numbers. This is a part of Mumbai University MCA Colleges C Program MCA SEM 1

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a,k;
clrscr();
printf("Enter the number :\n");
for(i=0;i<5;i++)
{
scanf("%d",&a[i][j]);
for(j=-0;j<5;j++)
{
scanf("%d",&a[i][j]);
if(k<a[i][j])
{
k=a[i][j];

}
}
}
printf("The largest number is%d\n",k);
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Swapping of Arrays C Program

This program accepts 20 numbers from user & stored in array of size 10 each & swap the value in these array at the corresponding location. This is a part of  Mumbai University MCA Colleges C Program MCA Sem 1

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a,b,temp,k;
clrscr();
printf("Enter the number in first array:\n");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the number in second array:\n");
for(j=0;j<10;j++)
{
scanf("%d",&b[j]);
}
for(k=0;k<10;k++)
{
temp=a[k];
a[k]=  b[k];
b[k]=temp;
printf("\n");
printf("The swapping number is :");
printf("%d\t%d\n",a[k],b[k]);
}
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Odd Numbers in Array C Program

This program accepts 10 numbers from user & stored in array & find out odd number in array & print. This is a part of Mumbai University MCA Colleges C programming MCA Sem 1

#include<stdio.h>
#include<conio.h>
void main()
{            int i,a;
clrscr();
for(i=0;i<=9;i++)
{   scanf("%d",&a[i]);

}         printf("\n The number is odd");
for(i=0;i<=10;i++)
{
if(a[i]%2!=0)
{
printf(" ");
printf("%d",a[i]);
}
}
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

### Pyramid of Numbers C program

This Program is to produced the following out put.
1
1 2 3
1 2 3 4 5
It is a part of Mumbai University MCA Colleges Programming in C MCA Sem 1

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1;i<=5;i=i+2)
{
printf("\n");
for(k=5;k>i;k=k-2)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d",j);
}
}
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.