Skip to content

Commit 4f6af37

Browse files
Add files via upload
1 parent e1a4ce7 commit 4f6af37

11 files changed

+234
-0
lines changed

2D-to-1D-Array.c

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include<stdio.h>
2+
#include<conio.h>
3+
int main(){
4+
int a[3][3],i,j,b[9],k=0;
5+
printf("Enter Elements for 2D Array.......");
6+
getch();
7+
for(i=0;i<3;i++){
8+
for(j=0;j<3;j++){
9+
printf("\nEnter Element a[%d][%d] : ",i,j);
10+
scanf("%d",&a[i][j]);
11+
}
12+
}
13+
getch();
14+
printf("\nThe Elements of 2D Array are....\n");
15+
getch();
16+
for(i=0;i<3;i++){
17+
for(j=0;j<3;j++){
18+
printf("a[%d][%d] = %d\t",i,j,a[i][j]);
19+
getch();
20+
}
21+
}
22+
printf("\nCopying into 1D Array.....");
23+
for(i=0;i<3;i++){
24+
for(j=0;j<3;j++){
25+
b[k]=a[i][j];
26+
k++;
27+
}
28+
}
29+
getch();
30+
printf("\nThe Elements of 1D Array are....\n");
31+
getch();
32+
for(k=0;k<9;k++){
33+
printf("b[%d] = %d\t",k,b[k]);
34+
getch();
35+
}
36+
return 0;
37+
}

Array_Reverse_Pointer.c

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<stdio.h>
2+
int main(){
3+
int a[5],*p,i;
4+
p=a;
5+
printf("Enter the Elements of Array : ");
6+
for(i=0;i<5;i++){
7+
printf("\nEnter Element %d : ",i+1);
8+
scanf("%d",p+i);
9+
}
10+
p+=4;
11+
printf("\nThe Elements of array in reverse order are : ");
12+
for(i=0;i<5;i++){
13+
printf("\t%d",*p);
14+
p--;
15+
}
16+
return 0;
17+
}

Array_Swapping_Pointer.c

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include<stdio.h>
2+
int main(){
3+
int x[5],y[5],i,*p,*q;
4+
p=x;q=y;
5+
printf("Enter the Elements of First Array : ");
6+
for(i=0;i<5;i++){
7+
printf("\nEnter Element %d : ",i+1);
8+
scanf("%d",p+i);
9+
}
10+
printf("Enter the Elements of Second Array : ");
11+
for(i=0;i<5;i++){
12+
printf("\nEnter Element %d : ",i+1);
13+
scanf("%d",q+i);
14+
}
15+
for(i=0;i<5;i++){
16+
*(p+i)=(*(p+i))+(*(q+i));
17+
*(q+i)=(*(p+i))-(*(q+i));
18+
*(p+i)=(*(p+i))-(*(q+i));
19+
}
20+
printf("\nFirst Array :");
21+
for(i=0;i<5;i++){
22+
printf("\t%d",*p);
23+
p++;
24+
}
25+
printf("\nSecond Array :");
26+
for(i=0;i<5;i++){
27+
printf("\t%d",*q);
28+
q++;
29+
}
30+
return 0;
31+
}

Assign-3-01.c

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Program to accept 5 number in any array and print it
2+
#include<stdio.h>
3+
int main(){
4+
int x[5],i;
5+
for(i=0;i<5;i++){
6+
printf("\nEnter Element %d : ",i+1);
7+
scanf("%d",&x[i]);
8+
}
9+
printf("\nThe Elements of the array are : ");
10+
for(i=0;i<5;i++){
11+
printf("%d\t",x[i]);
12+
}
13+
return 0;
14+
}

Assign-3-02.c

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Program to accept 5 number in any array and print in reverse order
2+
#include<stdio.h>
3+
int main(){
4+
int x[5],i;
5+
for(i=0;i<5;i++){
6+
printf("\nEnter Element %d : ",i+1);
7+
scanf("%d",&x[i]);
8+
}
9+
printf("\nThe Elements of the array in reverse order are : ");
10+
for(i=4;i>=0;i--){
11+
printf("%d\t",x[i]);
12+
}
13+
return 0;
14+
}

Assign-3-03.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Program to accept 5 number in any array copy to another array
2+
#include<stdio.h>
3+
#include<conio.h>
4+
int main(){
5+
int x[5],y[5],j;
6+
for(j=0;j<5;j++){
7+
printf("\nEnter Element %d : ",j+1);
8+
scanf("%d",&x[j]);
9+
}
10+
printf("\nThe Elements of the 1st array are : ");
11+
for(j=0;j<5;j++){
12+
printf("%d\t",x[j]);
13+
}
14+
printf("\nCopying the elements of 1st array into 2nd array");
15+
printf("\nThe Elements of the 2nd array are : ");
16+
for(j=0;j<5;j++){
17+
y[j]=x[j];
18+
printf("%d\t",y[j]);
19+
}
20+
return 0;
21+
}

Assign-3-04.c

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Program to accept 5 numbers in any array, another five number in second array and store the sum in third array
2+
#include <stdio.h>
3+
int main(){
4+
int x[5],y[5],z[5],k;
5+
printf("For 1st array");
6+
for(k=0;k<5;k++){
7+
printf("\nEnter element %d : ",k+1) ; scanf("%d",&x[k]);
8+
}
9+
printf("\nFor 2nd array");
10+
for(k=0;k<5;k++){
11+
printf("\nEnter element %d : ",k+1) ; scanf("%d",&y[k]);
12+
}
13+
printf("\nStoring the sum of elements of both the arrays in the third array");
14+
for(k=0;k<5;k++) {
15+
z[k]=x[k]+y[k];
16+
}
17+
printf("\nThe Elements of the third array are : ");
18+
for(k=0;k<5;k++){
19+
printf("%d ",z[k]);
20+
}
21+
return 0;
22+
}

Assign-3-05.c

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Program to accept 10 number in array and find the minimum number
2+
#include<stdio.h>
3+
int main(){
4+
int a[10],i,min=a[0];
5+
for(i=0;i<10;i++){
6+
printf("\nEnter Element %d : ",i+1);
7+
scanf("%d",&a[i]);
8+
}
9+
for(i=0;i<10;i++){
10+
if(a[i]<min) min=a[i];
11+
}
12+
printf("MINIMUM ELEMENT is %d",min);
13+
return 0;
14+
}

Assign-3-06.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Program to accept 10 number in array and find the maximum and minimum number
2+
#include<stdio.h>
3+
int main(){
4+
int a[10],i,max,min;
5+
for(i=0;i<10;i++){
6+
printf("\nEnter Element %d : ",i+1);
7+
scanf("%d",&a[i]);
8+
}
9+
max=a[0];
10+
min=a[0];
11+
for(i=0;i<10;i++){
12+
if(a[i]>max){
13+
max=a[i];
14+
}
15+
if(a[i]<min){
16+
min=a[i];
17+
}
18+
}
19+
printf("Max = %d\tMin = %d",max,min);
20+
return 0;
21+
}

Assign-3-07.c

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Program to accept 10 number in array and find the second highest number
2+
#include<stdio.h>
3+
int main(){
4+
int a[10],i,max1=0,max2=0;
5+
for(i=0;i<10;i++){
6+
printf("\nEnter Element %d : ",i+1);
7+
scanf("%d",&a[i]);
8+
}
9+
for(i=0;i<10;i++){
10+
if(a[i]>max1){
11+
max2=max1;
12+
max1=a[i];
13+
}
14+
else if(a[i]<max1){
15+
if(a[i]>max2){
16+
max2=a[i];
17+
}
18+
}
19+
}
20+
printf("\n1st MAX = %d\t2nd MAX = %d",max1,max2);
21+
return 0;
22+
}

Assign-3-08.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Program to accept 10 number in array and to the search specific number, entered by user
2+
#include<stdio.h>
3+
int main(){
4+
int a[10],i,n;
5+
for(i=0;i<10;i++){
6+
printf("\nEnter Element %d : ",i+1);
7+
scanf("%d",&a[i]);
8+
}
9+
printf("\nEnter any element to be searched : ");
10+
scanf("%d",&n);
11+
for(i=0;i<10;i++){
12+
if(n==a[i]){
13+
printf("%d found at index %d and position %d",n,i,i+1);
14+
break;
15+
}
16+
}
17+
if(n!=a[i])
18+
{ printf("%d is not present in array",n);
19+
}
20+
return 0;
21+
}

0 commit comments

Comments
 (0)