Posts

Showing posts with the label answer

SKILL ROCKS TECH THIRD QUESTION ANSWER

Q3 find the frequency of 1 to 9 from an array of size 100 having value 1 to 9 randomly arranged Conditions: 1. use only one loop. 2. do not use counters. 3. most efficiently  Answer suppose if array of 100 with random values between 1 to 9 were given then  simply answer is for(i=0;i<100;i++) {           count[ arr[i] ]++; // arr[i] is given array and count[] is frequency counter. } complete program is like this #include<conio.h> #include<iostream.h> #include<stdlib.h> void main() {     int arr[100],count[10],i,j;     clrscr();     for(i=0;i<20;i++)     {         arr[i]=random(10);     }     for(i=0;i<20; i++)     {         cout<<arr[i];         if(i%10==0)      ...