473,411 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

I can't seem to get the output this program, need some help

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. void what (char *str) {
  3.     if (*str) {
  4.     what (str+6);
  5.     putchar (*str-1);
  6. }
  7. return;
  8.  
  9. void main() {
  10. char *str = “\”YeN! cEnT! pEsO! pEnCe! LeMpIrA! pUls! Ha!!\””;
  11. what (str);
  12. putchar(‘\n’);
  13.  
  14. return;
  15. }
  16.  
Thanks shulapi
Jan 6 '08 #1
7 1459
------//-----
Here what I got after working on it: it needed some correction, I did. Found out what the output is but still don't know how the output is obtained.
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. void what (char *str) {
  3.     if (*str) 
  4.     {
  5.     what(str+6);
  6.     putchar (*str-1); 
  7.     }//if
  8.     return; 
  9.     }//what
  10.  
  11.  
  12. void main() {  // main() was complaining that is should be int but works with both int and void
  13. char *str="\"YeN! cEnT! pEsO! Kr0nEr! pEnCe! LeMpIrA! pUls! Ha!!\"";
  14. what(str);
  15. putchar('\n');
  16.  
  17. getchar();
  18. return;
  19. }//main
  20.  
it's output is: Good Job! (but can't see where the good job ! came from)
Jan 7 '08 #2
debasisdas
8,127 Expert 4TB
Question moved to C / C++ forum.
Jan 7 '08 #3
gpraghuram
1,275 Expert 1GB
------//-----
Here what I got after working on it: it needed some correction, I did. Found out what the output is but still don't know how the output is obtained.
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. void what (char *str) {
  3.     if (*str) 
  4.     {
  5.     what(str+6);
  6.     putchar (*str-1); 
  7.     }//if
  8.     return; 
  9.     }//what
  10.  
  11.  
  12. void main() {  // main() was complaining that is should be int but works with both int and void
  13. char *str="\"YeN! cEnT! pEsO! Kr0nEr! pEnCe! LeMpIrA! pUls! Ha!!\"";
  14. what(str);
  15. putchar('\n');
  16.  
  17. getchar();
  18. return;
  19. }//main
  20.  
it's output is: Good Job! (but can't see where the good job ! came from)

The good job came from this line
putchar (*str-1);
You are decrementing and printing a character.
Basically if the *str value is H then after decrementing it prints G

Raghuram
Jan 7 '08 #4
sicarie
4,677 Expert Mod 4TB
new4cprog-

Please don't forget to use code tags. Thanks.
Jan 7 '08 #5
The good job came from this line
putchar (*str-1);
You are decrementing and printing a character.
Basically if the *str value is H then after decrementing it prints G

Raghuram
Thanks alot Raghuram. I appreciate it. Thanks sicarie as well.
Shulapi
Jan 8 '08 #6
new4cprog-

Please don't forget to use code tags. Thanks.
sicarie - Thanks for the suggestion but I'm not familiar with code tags. I checked the link you provided but not much info as far how to do it. Thanks alot
Jan 10 '08 #7
sicarie
4,677 Expert Mod 4TB
Reading through the entirety of that page would have brought you to this:

# Make use of the available formatting tags in the forum Use CODE tags around your code unless you are posting a single line of code in which case it is acceptable to omit them:
The part immediately after tells you how to do it.
Jan 10 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John | last post by:
I am new to c++ programming and i just want to make a program that takes a users name, then converts it to a hex string, then puts it together in a fixed order. An example output would be: ...
6
by: Charles Law | last post by:
Suppose my application is running on a client machine, and they report an intermittent problem. It only occurs after the program has been running for a while, and then occasionally fails to perform...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
46
by: Ian Boyd | last post by:
IIS5, on a Windows 2000 Server machine. Debeg.WriteLine "Hello, world!" How can i view it?
16
by: saurabhnsit2001 | last post by:
The following program doesn't "seem" to print "hello-out". (Try executing it) #include <stdio.h> #include <unistd.h> int main() { while(1) { fprintf(stdout,"hello-out");
1
by: vv1 | last post by:
Write a C program for reading in a message string (with no blanks) and decoding the message. Store the decoded message in another string called outString. After decoding is complete, print...
2
by: sani8888 | last post by:
Hi everybody I am a beginner with C++ programming. And I need some help. How can I start with this program *********** The program is using a text file of information as the source of the...
8
by: dmoore | last post by:
Hi folks, I've seen the following issue come up in multiple posts to this mailing list: I have a python program that spawns a child process with popen or popen2 or popen3 or popen2.popen2...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.