can u tell me the reason that y we get this types of outputs

V

vinayakapuram

program1 :1

main()
{
printf("trip" "trapas");
}

output:trip traps

prog 2:
main()
{
prinf(5+ "bangalore");
}
output:lore

prog: 3
main()
{
n=5;
printf("\n n=%*d",n,n);
}
output:5
 
I

Ingo Menger

vinayakapuram said:
program1 :1

main()
{
printf("trip" "trapas");
}

output:trip traps

I don't believe it.
prog 2:
main()
{
prinf(5+ "bangalore");
}
output:lore

I don't beleive this either. Yet, there should be some messages from
the compiler and the linker about 'prinf'
prog: 3
main()
{
n=5;
printf("\n n=%*d",n,n);
}
output:5

Why is it so hard to tell the truth? You are lieing 3 times in a row.
 
K

Kenneth Brody

(Note that there are no words "u" and "y" in the English language.)
program1 :1

main()
{
printf("trip" "trapas");
}

output:trip traps

More likely, "triptrapas", as the above is the same as:

printf("triptrapas");
prog 2:
main()
{
prinf(5+ "bangalore");
}
output:lore

Hint 0: What is the proper spelling of "printf"?
Hint 1: What is the value of the expression 5+"bangalore"
Hint 2: Addition is commutative.
prog: 3
main()
{
n=5;
printf("\n n=%*d",n,n);
}
output:5

Actually, the above is invalid, as you never declare "n". However,
assuming you really meant "int n=5;" ...

Because n is 5. What would you expect the output to be?

However, I suspect that the output is really a newline followed by
" n= 5"

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:[email protected]>
 
S

Sandeep

vinayakapuram said:
program1 :1

main()
{
printf("trip" "trapas");
}
output:trip traps

"str1 " "str2" is often used to conctenate two constant strings
your code should print triptrapas without the space.
prog 2:
main()
{
prinf(5+ "bangalore");
}
output:lore
because printf accepts a char* (pointer address) and you are giving an
offset of 5 to that address.
prog: 3
main()
{
n=5;
printf("\n n=%*d",n,n);
}
output:5
printf accepts multiple parameters and ignores if a substitution is not
found ...

Apart from being very poorly written, you code was not compilable
without modifications. Please try to post compilable code.
 
P

Pedro Graca

vinayakapuram said:
program1 :1

main()

main *always* return an int.

int main(void)
{
printf("trip" "trapas");

The function printf does not have a prototype in scope.
You should include said:
}

output:trip traps

What compiler are you using?
I recommend you switch to one that produces executables that execute as
expected.

I'd expect any executable produced by a decent compiler for your
source code above to output "triptrapas" (minus the quotes).
<snip>
 
C

CBFalconer

Ingo said:
I don't believe it.

Nor I.
I don't beleive this either. Yet, there should be some messages from
the compiler and the linker about 'prinf'

Assuming printf in place of prinf, this is normal.
Why is it so hard to tell the truth? You are lieing 3 times in a row.

He may have simply elided blanks.

However the OP seems unable to write English. His article is full
of meaningless things such as 'u' and 'y'. He seems to enjoy
making it as hard as possible for anyone to assist him. That is
also why he typed in the program snippets with typos, in place of
cut and paste.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
 
I

Ingo Menger

CBFalconer said:
He may have simply elided blanks.

Maybe. But "n=" is still not blank.
That is
also why he typed in the program snippets with typos, in place of
cut and paste.

Maybe nobody has invented "cut and paste" yet in india.
 
S

Sandeep

You have not answered even a single question and given two useless
comments in the post so far - something you want to re-invent ?
 
K

Kenneth Brody

Ingo said:
Maybe. But "n=" is still not blank.

Nor is n necessarily of type "int".
Maybe nobody has invented "cut and paste" yet in india.

You didn't quote the previous sentences, which included:
However the OP seems unable to write English. and
He seems to enjoy making it as hard as possible for anyone to assist him.

My guess is the "he didn't cut-and-paste" refers to the latter sentence.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:[email protected]>
 
K

Kenneth Brody

Sandeep said:
vinayakapuram wrote: [...]
prog: 3
main()
{
n=5;
printf("\n n=%*d",n,n);
}
output:5
printf accepts multiple parameters and ignores if a substitution is not
found ...

True, but irrelevent here, as the format string expects 2 ints. (Check
the meaning of "*".) So, if n happens to be of type "int" (there is no
definition of "n" here), the above is valid code, and both parameters
are used.

[...]

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:[email protected]>
 
K

Keith Thompson

vinayakapuram said:
program1 :1

main()
{
printf("trip" "trapas");
}

output:trip traps

prog 2:
main()
{
prinf(5+ "bangalore");
}
output:lore

prog: 3
main()
{
n=5;
printf("\n n=%*d",n,n);
}
output:5

You've gotten a lot of criticism for this post. Let me explain why.

You put the question in the Subject: header. Not all news reading
software displays the subject header in a convenient manner. You need
to put the question in the body of the message as well.

Silly abbreviations like "u" for "you" and "y" for "why" are frowned
upon here. They make your writing very difficult to read, especially
for those whose native language isn't English. Minor spelling and
grammatical errors are ok, especially if English isn't *your* native
language, but please take the time to spell out the words. Standard
punctuation and capitalization are also very helpful.

The code you posted is not the same as the code that you compiled.
The first one doesn't produce the same output you say it does, the
second one misspells "printf" as "prinf", and the third doesn't
declare "n". All of them are missing the required
"#include <stdio.h>", and all of them should declare main as
"int main(void)" and have a "return 0" at the end.

You need to copy-and-paste the *exact* code that you fed to the
compiler rather than re-typing it. If you want help, don't make us
guess which errors were in your original code and which were
introduced when you re-typed it.

It's all about taking just a little extra effort to make it easier for
us to help you.

As for your questions:

1. Adjacent string literals are concatenated by the compiler.

2. A string literal represents an array. In most contexts, it's
implicitly converted to a pointer. You then perform pointer
arithmetic on the result. See section 6 of the comp.lang.c FAQ,
at <http://c-faq.com/>. (See the rest of it, too.)

3. Read the documentation for the printf function.
 
C

Charles Richmond

CBFalconer said:
[snip...] [snip...] [snip...]

However the OP seems unable to write English. His article is full
of meaningless things such as 'u' and 'y'. He seems to enjoy
making it as hard as possible for anyone to assist him. That is
also why he typed in the program snippets with typos, in place of
cut and paste.
y u wud think e wus st00pid or sum 10..... ;-)

I think it was Mark Twain who said: "There are *not* too many
stupid people, just an uneven distribution of lightning."
 
I

Ingo Menger

Sandeep said:
You have not answered even a single question

What question? The OP states "questions" of the form:

| Source: cflkasuhdpföasghnba.sfgbnöasfdkjh
| Output: kljydhlkjasdhgasldjkgfsd
| Please explain!

i.e., he asks us to comment on his lies. I did just that.
If you want honest answers, ask honest questions.

Moreover, every damn FAQ on this planet advises to ask that kind of
question in the form "I expected X, but it did Y", not just "explain".
Is it really too hard to show a minimum of gentle behaviour when one
needs help?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top