putchar, or write to the terminal.
U can write anything without using printf statement in c. but how?
putchar and its related commands
Reply:printf is really just a wrapper around the write() function.
use write and the stdout file descriptor with a pointer to the memory of your output statement and the amount of data to write.
For example.
char *ptr = "Hello World.\n";
write( 1, ptr, 13 );
to achieve the same as
fprintf( stdout, "%s", ptr );
Thursday, July 9, 2009
Suggest a definition for printf statement in c?
int printf(const char*,...);
Suggest a definition for printf statement in c?
Why not look it up in stdio.h?
int printf(const char *f,...);
Suggest a definition for printf statement in c?
Why not look it up in stdio.h?
int printf(const char *f,...);
Note on printf() functoin in c language?
I only briefly touched C++ before, so going on what i remember it is for displaying text.
Why do we put an address of operator in a scanf statement in C unlike in printf statement?
This is because while using scanf we store the scanned data from the user directly into the memory location of the variable which is denoted by the %26amp; operator, while in printf we wish to print the value stored in the variable, which is unrelated to memory location.
bouquet
bouquet
Can someone change this c++ program into another c language like (printf,scanf) this is calendar program?
#include %26lt;iostream%26gt;
#include %26lt;iomanip%26gt;
#include %26lt;string%26gt;
#include %26lt;cctype%26gt;
#include %26lt;ctime%26gt;
#include %26lt;cstdlib%26gt;
using namespace std;
// true if s1 is a prefix of s2, not case sensitive
bool prefix(const string%26amp; s1, const char* s2) {
for (int i=0;; ++i) {
if (i==int(s1.size()))
return true;
if (s2[i]==0 || tolower(s1[i])!=tolower(s2[i]))
return false;
}
}
// A Month represents a month and year, which prints as a calendar
class Month {
public:
Month(const string%26amp; m="", int y=0); // Defaults: this month and year
// m is the month name or prefix, not case sensitive
class Ambiguous {}; // Thrown if m matches %26gt;1 month name, e.g. "JU"
class Invalid {}; // Thrown if m matches no month name, e.g. "X"
void print(ostream%26amp; out) const; // Print a one month calendar to out
void add(int n) {now+=n;} // Add n months (may be negative)
private:
int now; // year * 12 + month (0=Jan, 11=Dec), e.g. 24001 means Feb. 2000
static con
Can someone change this c++ program into another c language like (printf,scanf) this is calendar program?
have u tried it yet
first try it urself and post the errors then after we will help ya
Reply:Yes, you may contact a C expert to convert it. Check websites like http://oktutorial.com/
Reply:its_tru_its_damm is right, first of all - you help yourself then ask from others.
#include %26lt;iomanip%26gt;
#include %26lt;string%26gt;
#include %26lt;cctype%26gt;
#include %26lt;ctime%26gt;
#include %26lt;cstdlib%26gt;
using namespace std;
// true if s1 is a prefix of s2, not case sensitive
bool prefix(const string%26amp; s1, const char* s2) {
for (int i=0;; ++i) {
if (i==int(s1.size()))
return true;
if (s2[i]==0 || tolower(s1[i])!=tolower(s2[i]))
return false;
}
}
// A Month represents a month and year, which prints as a calendar
class Month {
public:
Month(const string%26amp; m="", int y=0); // Defaults: this month and year
// m is the month name or prefix, not case sensitive
class Ambiguous {}; // Thrown if m matches %26gt;1 month name, e.g. "JU"
class Invalid {}; // Thrown if m matches no month name, e.g. "X"
void print(ostream%26amp; out) const; // Print a one month calendar to out
void add(int n) {now+=n;} // Add n months (may be negative)
private:
int now; // year * 12 + month (0=Jan, 11=Dec), e.g. 24001 means Feb. 2000
static con
Can someone change this c++ program into another c language like (printf,scanf) this is calendar program?
have u tried it yet
first try it urself and post the errors then after we will help ya
Reply:Yes, you may contact a C expert to convert it. Check websites like http://oktutorial.com/
Reply:its_tru_its_damm is right, first of all - you help yourself then ask from others.
What do I have to do to show a character with its number from the ASCII code in a printf in C++?
char c ; // previously assigned
printf( "Character = %c, ASCII = %d\n", c, (unsigned int) c ) ;
printf( "Character = %c, ASCII = %d\n", c, (unsigned int) c ) ;
What is the output of the following program in c and how? int i=3,j=2;printf("%d",i++ + ++j + --i + j--);?
what is the difference in c program
int i=3,j=2;
1)printf("%d",i++ + ++j + --i + j--);
and
2)p=i++ + ++j + --i + j--;
printf("%d",p);
What is the output of the following program in c and how? int i=3,j=2;printf("%d",i++ + ++j + --i + j--);?
well i can't remember c well but i know its similar to java
1-it is printing out the results of the variables from the formula given
2- it is assigning that formula to the variable P and then printing it out
Reply:Without actually trying it, I would think both would result in the same output. The main difference is the result in the second example is stored in p.
As for the value, since there are no parenthesis involved to modify order of processing, they are done in order left-to-right.
a) First, i is set to 3 and j to 2
b) i++ is added to the accumulator. Since it is a postfix ++, the value of 3 is added to accumulator before i is incremented to 4.
c) ++j is added to the accumulator. Since this is a prefix, 3 (the new value of j) is added in, making the accumulator 6.
d) --i makes the accumulator 8 after setting i back to 3.
e) j-- makes the accumulator 11 and then sets j back to 2.
In both cases, i and j are back at their original values and 11 is displayed (and stored, in the second example).
Reply:on is setting it into a variable before submitting it to the complier
ex p= %26lt;--- thatas a variable and he is just echoing it out... make sense?
Reply:The question is wrong. Output will be undefined. But some stubborn teachers don't agree.
There is a similar question which I asked in C forum. Read this :
http://cboard.cprogramming.com/showthrea...
http://www.research.att.com/~bs/bs_faq2....
Reply:the first printf prints 12
and the second prints 10
Reply:1) 12
2) 12
Reply:The answer for the first is it displays 12 and for the second undefined variable 'p'. because in "C" we have to declare a variable before we using it.
int i=3,j=2;
1)printf("%d",i++ + ++j + --i + j--);
and
2)p=i++ + ++j + --i + j--;
printf("%d",p);
What is the output of the following program in c and how? int i=3,j=2;printf("%d",i++ + ++j + --i + j--);?
well i can't remember c well but i know its similar to java
1-it is printing out the results of the variables from the formula given
2- it is assigning that formula to the variable P and then printing it out
Reply:Without actually trying it, I would think both would result in the same output. The main difference is the result in the second example is stored in p.
As for the value, since there are no parenthesis involved to modify order of processing, they are done in order left-to-right.
a) First, i is set to 3 and j to 2
b) i++ is added to the accumulator. Since it is a postfix ++, the value of 3 is added to accumulator before i is incremented to 4.
c) ++j is added to the accumulator. Since this is a prefix, 3 (the new value of j) is added in, making the accumulator 6.
d) --i makes the accumulator 8 after setting i back to 3.
e) j-- makes the accumulator 11 and then sets j back to 2.
In both cases, i and j are back at their original values and 11 is displayed (and stored, in the second example).
Reply:on is setting it into a variable before submitting it to the complier
ex p= %26lt;--- thatas a variable and he is just echoing it out... make sense?
Reply:The question is wrong. Output will be undefined. But some stubborn teachers don't agree.
There is a similar question which I asked in C forum. Read this :
http://cboard.cprogramming.com/showthrea...
http://www.research.att.com/~bs/bs_faq2....
Reply:the first printf prints 12
and the second prints 10
Reply:1) 12
2) 12
Reply:The answer for the first is it displays 12 and for the second undefined variable 'p'. because in "C" we have to declare a variable before we using it.
Subscribe to:
Posts (Atom)