Showing posts with label variable. Show all posts
Showing posts with label variable. Show all posts


how to compare char in c++

Assume that c is a char variable that has been declared and already given a value. Write an expression whose value is true if and only if c is NOT what is called a white space character (that is a space or a tab or a newline-- none of which result in ink being printed on paper).

(c==' ' || c=='\t' || c=='\n') ? false : true

calculate total= 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 using c++

Given an  int variable  n that has been initialized to a positive value and, in addition,  int variables  k and  total that have already been declared, use a  do...while loop to compute the sum of the cubes of the first  n whole numbers, and store this value in  total . Thus if  n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into  total . Use no variables other than  n ,  k , and  total .

while (k<=n);