Next declare a structure named reading with the following me

Next, declare a structure named reading, with the following members: windoSpeed: an int humidity: a double temperature: a TempScale structure variable

Solution

/****************declaration of structure tempScale and Reading***************/

//struct is a keyword for declaration of strucrure
struct TempScale{
/*variable declaration of structure*/
double fahrenheit;
double centigrade;
};

//struct is a keyword for declaration of strucrure
struct Reading{
/*variable declaration of structure*/
int windoSpeed;
double humidity;
struct TempScale temperature;
};

/*****************declaration End**************/

/*************accessing variable of structure in c***********/

#include <stdio.h>

//struct is a keyword for declaration of strucrure
struct TempScale{
/*variable declaration of structure*/
double fahrenheit;
double centigrade;
};

//struct is a keyword for declaration of strucrure
struct Reading{
/*variable declaration of structure*/
int windoSpeed;
double humidity;
struct TempScale temperature;
};

int main(){
struct Reading read;//creating varibale of Reading structure

/*Assigning dummy value to variable*/
read.windoSpeed=10;
read.humidity=40;
read.temperature.centigrade=10;
read.temperature.fahrenheit=10;
/*Printing value*/
printf(\"Centigrade = %g \ \",read.temperature.centigrade);
printf(\"Fahrenheit = %g \ \",read.temperature.fahrenheit);
printf(\"Humidity = %g \ \",read.humidity);
printf(\"WindoSpeed = %d\ \",read.windoSpeed);


return 0;
}


/************output**********/

raj@raj:~/Desktop/chegg$ gcc tempStruct.c
raj@raj:~/Desktop/chegg$ ./a.out
Centigrade = 10
Fahrenheit = 10
Humidity = 40
WindoSpeed = 10

If you have any query please feel free to ask.

Thanks a lot

 Next, declare a structure named reading, with the following members: windoSpeed: an int humidity: a double temperature: a TempScale structure variableSolution/

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site