1.
WACP to print the incremented values of an array
#include <stdio.h>
void main()
int a[100],n,i;
printf("enter size");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
a[i]++;
printf("after increment array values are");
for(i=0;i<n;i++)
printf("%d\t",a[i]);
2. W. A C. P to print reverse of an array elements
#include <stdio.h>
int main()
int a[50],i,j,n,b[50];
printf("enter n");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0,j=n-1;i<n;i++,j--)
b[i]=a[j];
for(j=0;j<n;j++)
printf("%d",b[j]);
return 0;
3. /* C program to create a one-dimensional array and find sum of the elements */
#include<stdio.h>
void main
int a[100], i, n, sum=0;
printf(“enter size:”);
scanf(“%d”, &n) ;
printf(“enter array elements \n”) ;
for( i=0; i<n; i++)
{
scanf(“%d”, &a[i]);
sum = sum+a[i];
printf(“the sum is = %d \n”,sum);
4. Write a c program to find the duplicate numbers in a given list of numbers.
#include <stdio.h>
int main()
int n, a[n];
printf("Enter size of the array\n");
scanf("%d",&n);
printf("Enter elements of the array\n");
for(int i = 0;i <n;i++)
scanf("%d",&a[i]);
printf("Duplicate elements in the list are\n");
for(int i = 0;i <n;i++)
for(int j = i+1; j <n;j++)
if(a[i] == a[j])
{
printf("%d\n",a[i]);
} }}}
5. W A C P to find transpose of a matrix
#include <stdio.h>
int main()
{
int r, c, i, j, a[10][10], t[10][10];
printf("Enter the number of rows and columns of matrix\n");
scanf("%d%d", &r, &c);
printf("Enter elements of the matrix\n");
for (i = 0; i < r; i++)
{
for(j = 0; j < c; j++)
{
scanf("%d", &a[i][j]);
}
}
for (i = 0; i < r; i++)
{
for( j = 0 ; j < c ; j++ )
{
t[j][i] = a[i][j];
}
}
printf("Transpose of the matrix:\n");
for( i = 0 ; i < c ; i++ )
{
for (j = 0; j < r; j++)
{
printf("%d\t", t[i][j]);
}
printf("\n");
}
return 0;
}
o/p:
Enter the number of rows and columns of matrix
2
3
Enter elements of the matrix
4 7 9
2 8 5
Transpose of the matrix:
4 2
7 8
9 5