it is about the "c language".
What is meant by preprocessor in "c language"?
It is a program that preprocess the source code before it is passed to the compiler.There r different kind of preprocessor command or directive like macro expansion, file inclusion,conditional compilation etc...
Reply:The preprocessor is one of the four tools that a compiler suite needs to compile your source code.
Being executed as first, the preprocessor looks in the source code for C macros and substitutes them against the corresponding code.
You can recognize those macros by the # in front of the keyword (#include, #pragma, #define, #ifdef, ...)
thank you cards
Tuesday, July 14, 2009
How to write this programe in Turbo C language?
Plz use Turbo C language instead of C++.And have to use for loops etc in this program.use stdio.h n conio.h only n use
printf() etc.................
........1
......121
....12321
..1234321
123454321
..1234321
....12321
......121
........1
How to write this programe in Turbo C language?
#include %26lt;stdio.h%26gt;
int main(void)
{
int i, w = 5, dx = 1;
for (i = 1; i %26gt;= 1; i += dx)
{
int pad;
if (i == w) dx = -1;
for (pad = w; pad %26gt; i; --pad)
putchar(' ');
for (pad = 1; pad %26lt;= i; ++pad)
putchar('0' + pad); /* This line prints eg: 1234 */
for (pad = i - 1; pad %26gt;= 1; --pad)
putchar('0' + pad); /* This line prints eg: 321 */
putchar('\n');
}
return 0;
}
printf() etc.................
........1
......121
....12321
..1234321
123454321
..1234321
....12321
......121
........1
How to write this programe in Turbo C language?
#include %26lt;stdio.h%26gt;
int main(void)
{
int i, w = 5, dx = 1;
for (i = 1; i %26gt;= 1; i += dx)
{
int pad;
if (i == w) dx = -1;
for (pad = w; pad %26gt; i; --pad)
putchar(' ');
for (pad = 1; pad %26lt;= i; ++pad)
putchar('0' + pad); /* This line prints eg: 1234 */
for (pad = i - 1; pad %26gt;= 1; --pad)
putchar('0' + pad); /* This line prints eg: 321 */
putchar('\n');
}
return 0;
}
Anyone can help me to make a "C language" program?
1. To convert hexadecimal to decimal
Suppose the input is :"4FDA12"
And the output should be:"5233170"
Suppose the input is :"F"
And the output is:"15"
2. To convert decimal to hexadecimal
Suppuse the input is "5233170"
And the output is "4FDA12"
Suppose the input is "15"
And the output is "F"
Please let me know how it work and how is the algorithm. I try to make it for 3 days but i confuse. I have a problem with how we save tomporaty the number and the counter to count how many digit is the output.
I still learn C language and i dont understand C++
Could someone please explain me and help me to build the 2 programs. I need the source code to improve my Algorithm skill.
:)
Thanks for ur help.
Good luck. Have a nice weekend..
Anyone can help me to make a "C language" program?
Just use strtoul to convert from string to integer, and sprintf
to convert from an interger back to a string.
Example 1:
val = strtoul(hexstr, NULL, 16); /* hex string to interger */
Example 2:
val = strtoul(decstr, NULL, 10); /* dec string to integer */
Example 3:
sprintf(hexstr, "%X", val); /* integer to hex string */
Example 4:
sprintf(decstr, "%d", val); /* integer to dec string */
If you're doing this for a class, then the instructor might have told
you that you are not allowed to use functions like strtoul and sprintf to do the conversion. In that case, you can do something like this...
// the dots at the beginning of each line are there because
// yahoo removes leading spaces
unsigned int hexstr2uint(char *hexstr)
{
. . unsigned int val = 0;
. . int temp;
. .
. . if (hexstr != NULL)
. . . . for( ; *hexstr ; hexstr++)
. . . . {
. . . . . . temp = hexchr2int( *hexstr );
. . . . . . if (temp == -1) /* stop if we reach an invalid char */
. . . . . . . . break;
.
. . . . . . val *= 16;
. . . . . . val += (unsigned int) temp;
. . . . }
.
. . return val;
}
You should be able to write the hexchr2int function, and
the decstr2uint function will be similar to the one I've shown
above.
To convert an integer to a string w/o using standard C functions...
char *uint2hexstr(unsigned int val, char *outbuf)
{
. . int digits[32], ndigits = 0, i = 0 ;
.
. . do
. . {
. . . . digits [ ndigits++ ] = val % 16;
. . . . val /= 16;
. . }
. . while(val %26gt; 0);
.
. . for ( i = 0; i %26lt; ndigits ; i++ )
. . . . outbuf [ i ] = int2hexchr(digits [ ndigits - i - 1 ]);
.
. . outbuf [ ndigits ] = '\0'; // null terminate
.
. . return outbuf;
}
again, you can write the int2hexchr function, and the
decimal version will be similar.
Reply:Is this your homework? You haven't posted your approach to solve the problem. If you do that I might be able to tell you where you are wrong. Anyway you take see for the algorithm at http://www.permadi.com/tutorial/numDecTo...
--
Ck
http://www.gfour.net
Suppose the input is :"4FDA12"
And the output should be:"5233170"
Suppose the input is :"F"
And the output is:"15"
2. To convert decimal to hexadecimal
Suppuse the input is "5233170"
And the output is "4FDA12"
Suppose the input is "15"
And the output is "F"
Please let me know how it work and how is the algorithm. I try to make it for 3 days but i confuse. I have a problem with how we save tomporaty the number and the counter to count how many digit is the output.
I still learn C language and i dont understand C++
Could someone please explain me and help me to build the 2 programs. I need the source code to improve my Algorithm skill.
:)
Thanks for ur help.
Good luck. Have a nice weekend..
Anyone can help me to make a "C language" program?
Just use strtoul to convert from string to integer, and sprintf
to convert from an interger back to a string.
Example 1:
val = strtoul(hexstr, NULL, 16); /* hex string to interger */
Example 2:
val = strtoul(decstr, NULL, 10); /* dec string to integer */
Example 3:
sprintf(hexstr, "%X", val); /* integer to hex string */
Example 4:
sprintf(decstr, "%d", val); /* integer to dec string */
If you're doing this for a class, then the instructor might have told
you that you are not allowed to use functions like strtoul and sprintf to do the conversion. In that case, you can do something like this...
// the dots at the beginning of each line are there because
// yahoo removes leading spaces
unsigned int hexstr2uint(char *hexstr)
{
. . unsigned int val = 0;
. . int temp;
. .
. . if (hexstr != NULL)
. . . . for( ; *hexstr ; hexstr++)
. . . . {
. . . . . . temp = hexchr2int( *hexstr );
. . . . . . if (temp == -1) /* stop if we reach an invalid char */
. . . . . . . . break;
.
. . . . . . val *= 16;
. . . . . . val += (unsigned int) temp;
. . . . }
.
. . return val;
}
You should be able to write the hexchr2int function, and
the decstr2uint function will be similar to the one I've shown
above.
To convert an integer to a string w/o using standard C functions...
char *uint2hexstr(unsigned int val, char *outbuf)
{
. . int digits[32], ndigits = 0, i = 0 ;
.
. . do
. . {
. . . . digits [ ndigits++ ] = val % 16;
. . . . val /= 16;
. . }
. . while(val %26gt; 0);
.
. . for ( i = 0; i %26lt; ndigits ; i++ )
. . . . outbuf [ i ] = int2hexchr(digits [ ndigits - i - 1 ]);
.
. . outbuf [ ndigits ] = '\0'; // null terminate
.
. . return outbuf;
}
again, you can write the int2hexchr function, and the
decimal version will be similar.
Reply:Is this your homework? You haven't posted your approach to solve the problem. If you do that I might be able to tell you where you are wrong. Anyway you take see for the algorithm at http://www.permadi.com/tutorial/numDecTo...
--
Ck
http://www.gfour.net
How to restart the system writing program using c/c++ language?
i want to know coding part (i mean program) how to restart my computer writing my own program using either c/c++ language
How to restart the system writing program using c/c++ language?
This trick is done, using the Windows API. Visit this link for some details:
http://www.codersource.net/mfc_shutdown_...
I hope this helps
Reply:no idea dont get a virus
Reply:frankly, I dont know if there is a uniform way of doing this.
but I can suggest a quick and dirty hack to do this
use something like
system("shutdown -r") on windows/linux etc.
These will invoke the native OS calls to do what you want. Its also really ugly. I am hoping someone else gives you a better way to solve this problem!
Reply:Using interrupts.. Refer Interrupt programmng in C - byu yeshwant kanethkar
Reply:There are two methods
1. Call the "shutdown.exe" (with params "/r" if you are on windows)
2. Send the system the appropriate termination signal
How to restart the system writing program using c/c++ language?
This trick is done, using the Windows API. Visit this link for some details:
http://www.codersource.net/mfc_shutdown_...
I hope this helps
Reply:no idea dont get a virus
Reply:frankly, I dont know if there is a uniform way of doing this.
but I can suggest a quick and dirty hack to do this
use something like
system("shutdown -r") on windows/linux etc.
These will invoke the native OS calls to do what you want. Its also really ugly. I am hoping someone else gives you a better way to solve this problem!
Reply:Using interrupts.. Refer Interrupt programmng in C - byu yeshwant kanethkar
Reply:There are two methods
1. Call the "shutdown.exe" (with params "/r" if you are on windows)
2. Send the system the appropriate termination signal
How to print the result in c language?
My actual question is how to print the result or some other thing using c language.
for example:
printf("\nName:X\nFrom:XX...........")...
output will be:
Name:x
From:XX..........
This output i should print in a paper.Pls help meeeee............
How to print the result in c language?
If you want to print variables and string using printf.. you will need to do:
printf("\nName:%s\nFrom:%s\n", str1, str2);
Output: (str1 = John, str2 = Yo)
Name: John
From: Yo
potential breakup song
for example:
printf("\nName:X\nFrom:XX...........")...
output will be:
Name:x
From:XX..........
This output i should print in a paper.Pls help meeeee............
How to print the result in c language?
If you want to print variables and string using printf.. you will need to do:
printf("\nName:%s\nFrom:%s\n", str1, str2);
Output: (str1 = John, str2 = Yo)
Name: John
From: Yo
potential breakup song
What is an identifier in the C language?give brief theme with examples and what is relation with variables?
Basics of C LANGUAGE
What is an identifier in the C language?give brief theme with examples and what is relation with variables?
An identifier is a human-readable name for a symbol. Symbol is short for symbolic representation of a memory location and/or its contents. Since both code and data reside in memory, a symbol can represent either a function or [what's commonly called] a variable.
Some say that, in the purest sense, a function is a variable -- to a degree that's true, but it's not common usage. Usually when someone says "variable" they're talking about a data declaration... usually but not always. (Warning: I'm about to crank-up the "confusing stuff knob" to 11.)
It is possible to declare a variable of type pointer to function, as opposed to declaring an actual function, e.g.,
// actual function
int foo(int bar)
{
return bar;
}
// define type "pointer to function that returns int,
// and accepts one int parameter"
typedef int (*LPFN_FOO)(int);
// declare a variable of type pointer to function [...], and assign
// the address of an actual function to it.
LPFN_FOO pFoo = foo;
// pFoo and foo can now be used interchangably
int a = pFoo(5);
int b = foo(5);
if (a == b)
printf("it's true!");
The point of all this is that in common usage the terms "variable" and "function" refer to two inherently different concepts/constructs. But that not withstanding, we see that sometimes the line between them blurs (so badly it almost vanishes) -- which serves to bring home the fact that functions and variables are just symbols, that are referenced in source code by their identifiers.
Reply:identifiers are basically a name for either a variable or a function.
variables are declared like this:
int varName;
int is the type of the variable (what kind of data it can hold) and varName is the name of the variable.
The significance is that you use the identifier to represent the variable, so if you wanted to assign the above variable a value you would do it like this:
varName = 10;
identifiers can all so be the names of functions and are declared like this:
int funcName(int varName)
{
//code...
}
where int is the return type, or what kind of data that function will return when called. funcName is the identifier by which the function is called, and int varName is a paramater.
the site in my sources is a great C tutorial.
What is an identifier in the C language?give brief theme with examples and what is relation with variables?
An identifier is a human-readable name for a symbol. Symbol is short for symbolic representation of a memory location and/or its contents. Since both code and data reside in memory, a symbol can represent either a function or [what's commonly called] a variable.
Some say that, in the purest sense, a function is a variable -- to a degree that's true, but it's not common usage. Usually when someone says "variable" they're talking about a data declaration... usually but not always. (Warning: I'm about to crank-up the "confusing stuff knob" to 11.)
It is possible to declare a variable of type pointer to function, as opposed to declaring an actual function, e.g.,
// actual function
int foo(int bar)
{
return bar;
}
// define type "pointer to function that returns int,
// and accepts one int parameter"
typedef int (*LPFN_FOO)(int);
// declare a variable of type pointer to function [...], and assign
// the address of an actual function to it.
LPFN_FOO pFoo = foo;
// pFoo and foo can now be used interchangably
int a = pFoo(5);
int b = foo(5);
if (a == b)
printf("it's true!");
The point of all this is that in common usage the terms "variable" and "function" refer to two inherently different concepts/constructs. But that not withstanding, we see that sometimes the line between them blurs (so badly it almost vanishes) -- which serves to bring home the fact that functions and variables are just symbols, that are referenced in source code by their identifiers.
Reply:identifiers are basically a name for either a variable or a function.
variables are declared like this:
int varName;
int is the type of the variable (what kind of data it can hold) and varName is the name of the variable.
The significance is that you use the identifier to represent the variable, so if you wanted to assign the above variable a value you would do it like this:
varName = 10;
identifiers can all so be the names of functions and are declared like this:
int funcName(int varName)
{
//code...
}
where int is the return type, or what kind of data that function will return when called. funcName is the identifier by which the function is called, and int varName is a paramater.
the site in my sources is a great C tutorial.
What can be created after learning c++ language, also how can i create my softwares?
HOW CAN I CREATE SOFTWARES?
WILL I BE ABLE TO CREATE SOFTWARES AFTER LEARNING C++ LANGUAGE?
What can be created after learning c++ language, also how can i create my softwares?
just learning the basic C++ language will not give you a handle on creating software apps. usually creating applications requires you to have a good handle on programming language. it will also mostly require that you know some form of database (either SQL, Access and Oracle). You will also most probably be working in a team (very few software apps are made by locking a programmer in a room and letting him/her churn out code).
WILL I BE ABLE TO CREATE SOFTWARES AFTER LEARNING C++ LANGUAGE?
What can be created after learning c++ language, also how can i create my softwares?
just learning the basic C++ language will not give you a handle on creating software apps. usually creating applications requires you to have a good handle on programming language. it will also mostly require that you know some form of database (either SQL, Access and Oracle). You will also most probably be working in a team (very few software apps are made by locking a programmer in a room and letting him/her churn out code).
Subscribe to:
Posts (Atom)