1.) Accept 10 Array values, Accept Searching Values then find the Searching Value found No of Times.
#include<stdio.h> #include<conio.h> void main() { int a[10],i,se,count=0; clrscr(); printf("Enter a 10 elements:"); for(i=0;i<10;i++) scanf("%d",&a[i]); printf("enter a searching value:"); scanf("%d",&se); for(i=0;i<10;i++) { if(a[i]==se) count++; } if(count==0) printf("The value not Found"); else printf("the searching value found:%d times",count); getch(); } |
Output:-
2.) Accept 10 Array values, the perform Searching and replacing Operations.
#include<stdio.h> #include<conio.h> void main() { int a[10],i,se,rep; clrscr(); printf("Enter a 10 elements:"); for(i=0;i<10;i++) scanf("%d",&a[i]); printf("enter a searching value:"); scanf("%d",&se); printf("enter a replacing value:"); scanf("%d",&rep); for(i=0;i<10;i++) { if(a[i]==se) a[i]=rep; } printf("value after repalcing:\n"); for(i=0;i<10;i++) { printf("%d\n",a[i]); } getch(); } |
Output:-
3.) Accept 10 Array values, the perform deleting an element in to an existing array.
#include<stdio.h> #include<conio.h> void main() { int a[10],i,pos; clrscr(); printf("Enter a 10 elements:"); for(i=0;i<10;i++) scanf("%d",&a[i]); printf("enter a position to delete:"); scanf("%d",&pos); for(i=pos-1;i<9;i++) a[i]=a[i+1]; for(i=0;i<9;i++) printf("%d\n",a[i]); getch(); } |
Output:-
________________________________________
_______________________________________________________________________________
Post a Comment