tag:blogger.com,1999:blog-959939550345671470.post1817380545082450070..comments2024-03-24T12:51:18.535+05:30Comments on C programming Interview questions and answers: DELETE ELEMENT FROM AN ARRAY AT DESIRED POSITION USING CPriyanka kumarihttp://www.blogger.com/profile/08145649011863585828noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-959939550345671470.post-5706457090461445452016-10-09T12:48:50.850+05:302016-10-09T12:48:50.850+05:30Modified code is :
#include
int main()
{
i...Modified code is :<br /><br /><br />#include <br /><br />int main()<br />{<br /> int a[100],i,n,pos,k;<br /><br /> printf("Enter the size of array : ");<br /> scanf("%d",&n);<br /><br /> printf("Enter %d elements int the array : ",n);<br /> for(i=0;i<n;i++)<br /> scanf("%d",&a[i]);<br /><br /> printf("Enter the Anonymoushttps://www.blogger.com/profile/18379364507368058235noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-11039999516864469322016-10-09T12:41:29.183+05:302016-10-09T12:41:29.183+05:30simple code is here
#include
int main()
{
...simple code is here<br /><br /><br />#include <br /><br />int main()<br />{<br /> int a[100],i,n,pos;<br /><br /> printf("Enter the size of array : ");<br /> scanf("%d",&n);<br /><br /> printf("Enter %d elements int the array : ",n);<br /> for(i=0;i<n;i++)<br /> scanf("%d",&a[i]);<br /><br /> printf("Enter the Anonymoushttps://www.blogger.com/profile/18379364507368058235noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-90392123033004351752015-11-04T22:31:03.506+05:302015-11-04T22:31:03.506+05:30gud
gud<br />Anonymoushttps://www.blogger.com/profile/09636642881416484477noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-58471076130649955122015-04-25T12:13:02.344+05:302015-04-25T12:13:02.344+05:30yes it does ...note that the position here starts ...yes it does ...note that the position here starts from 1 not 0Shalini Vhttps://www.blogger.com/profile/03350245730330557732noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-86367395621994334472015-02-25T20:12:20.417+05:302015-02-25T20:12:20.417+05:30guys dere are two errors in the source code
first...guys dere are two errors in the source code<br /><br />firstly have a look at the second while loop from the bottom <br />it shud be while(i!=pos)<br />secondly in the first while loop from the bottom it shud be while(i<size)<br />:)Anonymoushttps://www.blogger.com/profile/11623744316385014562noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-21037771495896592102014-04-05T18:09:17.078+05:302014-04-05T18:09:17.078+05:30if the value of i is less than 10... for example t...if the value of i is less than 10... for example the value of i is 0 then the condition is false because 0<br /> is less than 10<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-88599668438385075062013-12-16T10:24:08.829+05:302013-12-16T10:24:08.829+05:30actually the above program is to count a number th...actually the above program is to count a number that is repeating maximum times for example array input is {1,1,1,2,2,2,3,3,4} then output is {1,2} orlese if input is {2,2,2,11,1,3,3,4} then output is {1}<br />regards <br />cherryAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-21629423305957551372013-12-16T10:09:49.960+05:302013-12-16T10:09:49.960+05:30#include
#include
void main()
{
int a[10],count[20...#include<br />#include<br />void main()<br />{<br />int a[10],count[20],i,j,n,count1[20],max,b[10],init;<br />clrscr();<br />printf("Enter the array size\n");<br />scanf("%d",&n);<br />printf("Enter the array elements\n");<br />for(i=0;icount1[j])<br /> {<br /> count1[i]=count1[i]+count1[j];<br /> count1[j]=count1[i]-count1[j];<br /> count1Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-84493655738469767042013-08-22T21:23:09.592+05:302013-08-22T21:23:09.592+05:30i think here should be while(i<size).... ???...i think here should be while(i<size).... ???<br />am i right????<br />Anonymoushttps://www.blogger.com/profile/07735417457194510486noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-77570309842991163042013-08-22T21:20:53.478+05:302013-08-22T21:20:53.478+05:30what is the meaning of while(i<10) .
i cant...what is the meaning of while(i<10) .<br />i cant understand.....Anonymoushttps://www.blogger.com/profile/07735417457194510486noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-90094902562116449682013-05-22T07:03:48.767+05:302013-05-22T07:03:48.767+05:30shouldn't it be like this.
-------------------...shouldn't it be like this.<br />----------------------<br /><br /> if (pos < size) {<br /> i=(pos-1);<br /> while(i<size){<br /> a[i]=a[i+1];<br /> i++;<br /> }<br /> }Ashish Guptahttp://www.google.comnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-74088347324474054522012-09-14T22:55:18.439+05:302012-09-14T22:55:18.439+05:30This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/15523895473739556988noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-80151897080710295442012-08-19T15:49:52.615+05:302012-08-19T15:49:52.615+05:30printf("enter the position at which element h...printf("enter the position at which element has to be deleted");<br /> scanf("%d",&loc);<br />for(i=loc-1;i<n-1;i++)<br /> a[i]=a[i+1];<br />for(i=0;i<n-1;i++)<br /> printf("%d\n",a[i]);<br />system("pause");<br />}Anonymoushttps://www.blogger.com/profile/10091522577582902407noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-84846397364781563512012-07-10T02:46:05.216+05:302012-07-10T02:46:05.216+05:30i think it shud b (i!=pos) in first while loop..m...i think it shud b (i!=pos) in first while loop..m i correct..??Anonymoushttps://www.blogger.com/profile/11743241400087768417noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-36863107867490833452012-03-03T16:55:15.095+05:302012-03-03T16:55:15.095+05:30The last element still occupies memory but is not ...The last element still occupies memory but is not being shown.<br /><br />So technically you have made it invisible and not deleted it.Jatin Sindhuhttps://www.blogger.com/profile/15853932758382445716noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-25174097407424552992012-02-13T23:41:28.198+05:302012-02-13T23:41:28.198+05:30i think there is a problem in it......i think there is a problem in it......Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-50764129590468999722011-10-31T18:26:18.475+05:302011-10-31T18:26:18.475+05:30your program doesn't actually delete the last ...your program doesn't actually delete the last element does it?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-48443448949395356842011-10-24T20:59:58.532+05:302011-10-24T20:59:58.532+05:30Why is that i<10? Please explain it.Why is that i<10? Please explain it.Zainnoreply@blogger.com