





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Nmae: Jubaer Ahmed ID: 213-15- Section: PC-C #include<stdio.h> #include<stdlib.h> int main() { int x[100], y[10][10]; int a, b; ** Problem- for(a=0; a<100; a++) x[a]=rand()%1000; printf("Elements of 1D array are as follow: \n"); for (a=0; a<100; a++) printf("%d ",x[a]); for(a=0; a<10; a++) for(b=0; b<10; b++) y[a][b]=rand()%1000; printf("\nElements of 2D array are as follow: \n"); for (a=0; a<10; a++) for(b=0; b<10; b++) printf("%d ",y[a][b]); printf("\n");
** Output: Elements of 1D array are as follow: 41 467 334 500 169 724 478 358 962 464 705 145 281 827 961 491 995 942 827 436 391 604 902 153 292 382 421 716 718 895 447 726 771 538 869 912 667 299 35 894 703 811 322 333 673 664 141 711 253 868 547 644 662 757 37 859 723 741 529 778 316 35 190 842 288 106 40 942 264 648 446 805 890 729 370 350 6 101 393 548 629 623 84 954 756 840 966 376 931 308 944 439 626 323 537 538 118 82 929 541 Elements of 2D array are as follow: 833 115 639 658 704 930 977 306 673 386 21 745 924 72 270 829 777 573 97 512 986 290 161 636 355 767 655 574 31 52 350 150 941 724 966 430 107 191 7 337 457 287 753 383 945 909 209 758 221 588 422 946 506 30 413 168 900 591 762 655 410 359 624 537 548 483 595 41 602 350 291 836 374 20 596 21 348 199 668 484 281 734 53 999 418 938 900 788 127 467 728 893 648 483 807 421 310 617 813 514
printf("1D array even & odd numbers are: \n"); int even, odd; even = 0; odd = 0; for(a=0; a<100; a++) if(x[a]%2==0) even++; else odd++; printf("Even numbers: %d\n Odd numbers: \n", even, odd); printf("\n2D array even & odd numbers are: \n"); for(a=0; a<10; a++) for(b=0; b<10; b++) if(y[a][b]%2==0)
int item1, item2; int count1 = 0; int count2 = 0; printf("Enter The item to be searched in one-dimensional array: \n"); scanf("%d",&item1); for(a=0; a<100; a++) if(x[a]==item1) count1++; printf("Enter The item to be searched in two-dimensional array: \n"); scanf("%d",&item2); for(a=0; a<10; a++) for(b=0; b<10; b++) if(y[a][b]==item2) count2++; printf("The occurences of %d in one-dimensional array is %d item", item1, count1); printf("\n The occurences of %d in two-dimensional array is %d item\n", item2, count2); Problem 06: printf("Enter the number of element: "); scanf("%d", &n); printf("Enter %d integers\n", n); for(a=0;a<n;a++) { scanf("%d", &x[a]); }
for(a=0;a<n;a++) { for(b=0;b<n-1;b++) { if(x[b]>x[b+1]) { temp = x[b]; x[b] = x[b+1]; x[b+1]=temp; } } } printf("After shorting the ascending order list:\n"); for(a=0;a<n;a++) { printf(" %d ", x[a]); } printf("\n") _Problem 07:_** int C[10], D[10], size1, size2, k, merge[20]; printf("Enter Array 1 Size: "); scanf("%d", &size1); printf("Enter Array 1 Elements:\n "); for(a=0; a<size1; a++) { scanf("%d", &C[a]);
Enter Array 2 Elements: 1 5 2 3 6 4 Array merging is: 1 2 2 3 4 1 5 2 3 6 4 _Problem 08:_** #include<stdio.h> #include<stdlib.h> int main() int m[10][10], n[10][10], jub[10][10], a, b, c, d, e; printf("Number of row and column: "); scanf("%d, %d", &a, &b); if(a==b) { printf("The first matrix element=\n"); for(c=0; c<a; c++) { for(d=0; d<d; d++) { scanf("%d", &jub[c][d]); }
printf("enter the second matrix element=\n"); for(c=0; c<a; c++) { for(d=0; d<b; d++) { scanf("%d", &n[c][d]); } } printf("Multiply of the matrix=\n"); for(c=0; c<a; c++) { for(d=0; d<b; d++) { jub[c][d]=0; for(e=0; e<b; e++) { jub[c][d]+=m[c][e]*n[e][d]; } } } for(c=0; c<a; c++) { for(d=0; d<b; d++) { printf("%d\t", jub[c][d]);