Random C Stuff.

/**
 *Without using /, % or * operator, write a function to divide a number by 3.
 **/

#include



int divideby3(int);



int main(int argc,char **argv)

{

    int res;

    res = divideby3(9);

    printf("%d",res);

    return 0;

}



int divideby3(int aNumber)

{

    div_t d = div(aNumber, 3);

    return d.quot;

}

Never have explored the capablities of stdlib The C standard library, sometimes referred to as libc, is the standard library for the C programming language, as specified in the ISO C standard. Starting from the original ANSI C standard, it was developed at the same time as the C POSIX library, which is a superset of it. Since ANSI C was adopted by the International Organization for Standardization, the C standard library is also called the ISO C library. . Infact, with C Programming Language out of touch for so many months, I was thinking this program will seriously fail, thinking kind of how come div_t datatype, d.quote (object.property ?) etc. gcc The GNU Compiler Collection (GCC) is a collection of compilers from the GNU Project that support various programming languages, hardware architectures, and operating systems. The Free Software Foundation (FSF) distributes GCC as free software under the GNU General Public License (GNU GPL). GCC is a key component of the GNU toolchain which is used for most projects related to GNU and the Linux kernel. With roughly 15 million lines of code in 2019, GCC is one of the largest free programs in existence. It has played an important role in the growth of free software, as both a tool and an example. will crib saying dont using c++. But it worked perfectly fine.


umm, structs In the C programming language, struct is the keyword used to define a composite, a.k.a. record, data type – a named set of values that occupy a block of memory. It allows for the different values to be accessed via a single identifier, often a pointer. A struct can contain other data types so is used for mixed-data-type records. For example a bank customer struct might contains fields: name, address, telephone, balance. are part of standard C.

div_t is a struct:

/* Returned by `div'.  */



typedef struct



{



int quot;                   /* Quotient.  */



int rem;                    /* Remainder.  */



} div_t;

bluesmoon


Yes , I realized about struct datatype in C and unfortunately forgot the mention that in the post. All I was thinking about is, it was so out-of-mind (due to out-of-sight) and all obj.property and obj.method was what coming up.

Senthil