4
Contributors
11
Replies
14
Views
4 Years
Discussion Span
Last Post by deceptikon
0

tried a lot but unable 2 put in any of loop,i know it simply with printf stmts but with loop cant do it,plz help me out it's urgent ........

1
do
{
    printf("|......|\n");
    printf("|..c...|\n");
    printf("|..ch..|\n");
    printf("|..chm..|\n");
}
while (0);
Votes + Comments
thanks for helping me out and can u tell me this using for loop
0

Maybe a more serious answer is in order..

Try to create a function that will prefix a given character array with "|.." and postfix it with "..|". The character section should always be atleast 2 symbols, use '.' to fill up remaining spaces if needed. (so that would be if the supplied character array has size 0 or 1) You could then create a loop to call this function with an array and call it with size 0, 1, 2 and 3 using the same array.. ('c','h' and 'm')

Edited by Gonbe

0

is PI is a valid variable name?
according to me it is valid variable name because pi is reserved for the value 3.14.
please reply soon.

0

It's fine to use. math.h might define M_PI but this is only if

__STRICT_ANSI__ 

is defined. As a result some implementation might not have it either I think. If it does have it and it's defined, you wouldn't be able to define M_PI yourself when including math.h unless you use shady compiler-specific intructions to temporarily disable the definition like this:

#include <stdio.h>
#include <math.h>

int main(void)
{
    #pragma push_macro("M_PI")
    #undef M_PI
    double M_PI = 1.00;

    printf("%f\n", M_PI);
    #pragma pop_macro("M_PI")

    return 0;
}

While supported by quite some compilers I do not recommend this, just rename your variable if needed.

Edited by Gonbe

0

math.h might define M_PI but this is only if
__STRICT_ANSI__
is defined.

Everything in this statement is making an assumption about the implementation. Neither M_PI nor __STRICT_ANSI__ are required by the C standard. M_PI is a common extension though, so it would be best to safely define it if you use it in portable code:

#ifndef M_PI
#define M_PI 3.1415926535
#endif

And because both PI and M_PI have well established meanings, it would be unwise to use those names as anything but a constant for the value of pi. Or at most a working variable that eventually ends up at an approximation of pi.

0

in simple words tell me PI is an valid variable name or not???????????

Technically, yes. In real life, it depends on your compiler and the libraries you're using. If you need simpler words than that, the answer is no.

Edited by deceptikon

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.