Question:
C++ code statements....?
2008-03-18 05:08:58 UTC
I've been ask to choose 4 different types of fundamental data types in C++ then write C++ code statements to declare and initialise a variable of each type...I really dont understand what this question is talking about but 4 data types I could think of are:
Integers, Float, Characters and Double
Could someone clarify what the question means and please a little help on it?????????? Thanks guys and gals =).........
Six answers:
jwn
2008-03-18 05:21:59 UTC
declaring is like saying there is an identifier called with "...."

example:

int i; (we delared an integer i)



initializing the variable

i = 0; (initial value of i is 0)



declaring and initializing at the same time is like:

int i = 0;



the 4 data types are as follows:

int (for integers)

float (for numbers with decimal points)

char (for characters)

double (for higher precision numbers)
HandyManOrNot
2008-03-18 05:13:32 UTC
Sounds like you understand it! Just write 4 statements that declare and inititalize each of those types!
lede
2016-10-22 02:58:22 UTC
This is composed of taking each and every for fact aside into its 3 elements and rewriting each and every as a lengthy time period fact. seem up the syntax of the for and at the same time as statements and seem at 3 needed steps. Do the outer for first, then once you've finished it, do the inner for. desire that facilitates.
payne747
2008-03-18 05:14:14 UTC
It's pretty basic stuff.... Decare a variable of each type, e.g.



int num;

float cost;

bool choice;

// etc etc



Then initialize them by assigning each a value...



num=1;

float=1.0

bool = true;



Alternatively, you could just declare and initialize together,



int num=1;

float cost=1.0;

bool choice=true;
Varbiie
2008-03-19 05:18:36 UTC
Sorry sis, mi no save so mi nonap ansarim displa
Rayon
2008-03-18 05:16:32 UTC
struct myvariablen{

int ia;

float fa;

char ca;

double da;

};



then in programm u can use it like this:

myvariablen myvar;

myvar.fa = 3.2;

myvar.ca = "a";

myvar.ia="2";


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...