Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int select;
- printf("\n 1. C program to delete element from an array");
- printf("\n 2. C program to find reverse of array");
- printf("\n 3. C Program to find the sum of all elements of each column of a matrix");
- printf("\n\n Select any program you want to Run :");
- scanf("%d", &select);
- if(select == 1){
- int array[50], addnumber, removenumber, stored,option, arr,found=0;
- printf("\n\n 1) press 1 to Number of array");
- printf("\n 2) press 2 to addnumber");
- printf("\n 3) press 3 to removenumber");
- printf("\n 4) press 4 to show the result");
- printf("\n\n enter any option: ");
- scanf("%d", &option);
- if(option == 1){
- printf("\n\nEnter number of elements in array:");
- scanf("%d", &arr);
- printf("\n\n you have %d elements slot", arr);
- printf("\n\n enter any option: ");
- scanf("%d", &option);
- if(option == 2){
- printf("\nEnter the elements you want to show: \n");
- for(addnumber = 0; addnumber < arr; addnumber++)
- scanf("%d", &array[addnumber]);
- printf("you added these numbers : ");
- for(addnumber = 0; addnumber < arr; addnumber++)
- printf("%d ", array[addnumber]);
- printf("\n\n enter any option: ");
- scanf("%d", &option);
- if(option == 3){
- printf("\n\nEnter the element to be deleted: ");
- scanf("%d", &removenumber);
- for(addnumber=0; addnumber < arr; addnumber++){
- if(array[addnumber] == removenumber)
- {
- found = 1;
- stored = addnumber;
- continue;
- }
- }
- if(found == 1)
- {
- for(addnumber = stored; addnumber < arr-1; addnumber++)
- array[addnumber] = array[addnumber+1];
- }
- else{
- printf("\n\nElement %d is not found in the array\n\n", removenumber);
- }
- printf("\n\n enter any option: ");
- scanf("%d", &option);
- if(option == 4){
- printf("\n\nResultant array is: ");
- for(addnumber = 0; addnumber < arr-1; addnumber++)
- printf("%d ",array[addnumber]);
- }
- }
- }
- else if (option == 1){
- printf("\nyou Already decided the size\n");
- }
- else{
- printf("\nplease enter the numbers first\n");
- }
- }
- else if(option == 2 || option == 3 || option == 4){
- printf("\n Please add some number first");
- }
- }
- else if(select == 2) {
- int arr2[50], arrsize, addNumbers, option2;
- printf("\n\n 1) Add size of array");
- printf("\n 2) Add arrays numbers");
- printf("\n 3) Reverse numbers");
- printf("\n Enter the option : ");
- scanf("%d", &option2);
- if(option2 == 1){
- printf("Enter size of the array: ");
- scanf("%d", &arrsize);
- printf("\n Enter the option : ");
- scanf("%d", &option2);
- if (option2 == 2){
- printf("\n Enter the numbers to add in arrays : \n");
- for(addNumbers=0; addNumbers < arrsize; addNumbers++){
- scanf("%d", &arr2[addNumbers]);
- }
- printf("\n Enter the option : ");
- scanf("%d", &option2);
- if(option2 == 3){
- printf("\nReverse order of your added array : \n");
- for(addNumbers=arrsize-1; addNumbers >= 0; addNumbers--){
- printf("%d\n", arr2[addNumbers]);
- }
- }
- }
- else if (option2 == 1){
- printf("you already decide the size");
- }
- else{
- printf("add numbers first");
- }
- }
- else{
- printf("\n Please decide the size of array first \n");
- }
- }
- else{
- int maxrow= 10;
- int maxcol = 10;
- int matrix[maxrow][maxcol];
- int row, col, sum, product, i,j;
- printf("\n\nenter number of Rows: ");
- scanf("%d", &row);
- printf("\nenter number of columns: ");
- scanf("%d",&col);
- printf("Enter the matrix numbers : \n");
- for(i = 0; i<row; i++){
- for(j=0; j< col; j++){
- printf("\nEnter Numbers [%d,%d]",i+1, j+1);
- scanf("%d", &matrix[i][j]);
- }
- }
- printf("\n");
- for (i=0; i<row;i++){
- sum=0;
- for(j=0;j<col;j++){
- printf("%d\t", matrix[i][j]);
- sum += matrix[i][j];
- }
- printf("\t Sum : %d", sum);
- printf("\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement