Sunday, August 2, 2009

C programming simple help?

Can u solve this for me


1.Write a program which will read int vector (max leinght 100) and another int.Then the programm should show how many times, the int number will appear in the vector


I need this exercise to understand the vectors cause i can't right now :(, can u plz help me and give me an explanations about the steps...


thanx a ton

C programming simple help?
I think you mean Array from vector. if that's so,





int count = 0, array[100];


int b;


int count2, countB = 0;





for ( ; count %26lt; 100, array[count] != 0 ; count++)


/* array[count] != 0, we need this for stopping condition. u can use any thing */


{


scanf("%d",array[count] );


// each time you enter a value, it will be stored in the array


}








// now take the value which u want to check appearance





scanf("%d",%26amp;b);





// now another loop to go through the array.





for ( count2 = 0; count2 %26lt; count ; count2 ++ )


/* I think u know why "count2%26lt;count". because from 100 of the array size just the amount of "count" we have values. it is possibly can be 100, but just in case we have less than 100 values */


{


if ( array [count2] == b)


countB ++;


}





// it will go through the array and finds any occurrence of value b and if it finds one, adds one to countB so countB contains the number of occurrence.








change the name "array" if its a reserved name.
Reply:You should post the code you have so far and you'll get far better answers.
Reply:int a = 100;


int b;


printf("Enter: ");


scanf("%i", %26amp;b);


b = a/b;


I think thats what you want so a = 100, b is given integer-value from STDIN. Then using order of b goes in to a how many times, then store this in b
Reply:Drink Coffee or take a stimulant. When I do it. I write programs that I could never write normally.
Reply:This page may be of some help to you.





http://yepoocha.blogspot.com





-Adios-Element


No comments:

Post a Comment