Pages

Friday, 9 February 2018

A company planning to launch a new newspaper in market conducts a survey. The various parameters considered in the survey were, the economic status (upper, middle, and lower class) the languages readers prefer (English, Hindi, Regional language) and category of paper (daily, supplement, tabloid). Write a program, which reads data of 10 respondents through keyboard, and stores the information in an array of integers. The bit-wise information to be stored in an integer is given below: Bit Number Information 0 Upper class 1 Middle class 2 Lower class 3 English 4 Hindi 5 Regional Language 6 Daily 7 Supplement 8 Tabloid At the end give the statistical data for number of persons who read English daily, number of upper class people who read tabloid and number of regional language readers.


A company planning to launch a new newspaper in market conducts a survey. The various parameters considered in the survey were, the economic status (upper, middle, and lower class) the languages readers prefer (English, Hindi, Regional language) and category of paper (daily, supplement, tabloid). Write a program, which reads data of 10 respondents through keyboard, and stores the information in an array of integers. The bit-wise information to be stored in an integer is given below:
Bit Number Information
0 Upper class
1 Middle class
2 Lower class
3 English
4 Hindi
5 Regional Language
6 Daily
7 Supplement
8 Tabloid
At the end give the statistical data for number of persons who read English daily, number of upper class people who read tabloid and number of regional language readers.

#include<stdio.h>
#include<conio.h>
void main() {

int arr[10][3],i,j;
unsigned int infr;
int eng=0,utab=0,rgl=0;

for(i=0;i<10;i++) {

clrscr();

gotoxy(20,2);
printf("Enter data of respondent %d:\n\n",i+1);

for(j=0;j<3;j++) {

if(j==0){
printf("Economic Status:\n\n");
printf("0: Upper class\t1: Middle class\t2: Lower class\n\n");

scanf("%d",&arr[i][j]);
}

if(j==1){
printf("\n\nLanguage Preferred:\n\n");
printf("3: English\t4: Hindi\t5:Regional Language\n\n");

scanf("%d",&arr[i][j]);
}

if(j==2){

printf("\n\nType of Paper:\n\n");
printf("6: Daily\t7: Supplement\t8: Tabloid\n\n");


scanf("%d",&arr[i][j]);
}

}
}


/***********************************************/
/* converting the whole array using left shift */
/***********************************************/


for(i=0;i<10;i++) {

for(j=0;j<3;j++) {

arr[i][j]= 1 << arr[i][j];  /* conversion */

 }
}


for(i=0;i<10;i++) {

if(arr[i][1]==8)    /* english readers */
eng++;

if(arr[i][0]==1 && arr[i][2]==256)  /* upper class,tabloid readers */
utab++;

if(arr[i][1]==32) /* regional language readers */
rgl++;
}

clrscr();

gotoxy(20,2);
printf("Reader's statistics:\n\n\n\n");
printf("\tEnglish Reader: %d\n",eng);
printf("\tUpper class Tabloid Readers: %d\n",utab);
printf("\tRegional Language readers: %d\n",rgl);
getch();

}