• 0

[c++] need some editing help


Question

basically, this is what i have to do:

In case 1 for the switch

(b) print a blank line, a line with the message:"Part I:" and a blank line.

? Prompt the user to enter a text message from the keyboard

and accept a text from the keyboard by using gets().

(d) Print the original message on the screen.

(e) Find the number of characters in the message by using strlen() and

print the message in the reverse order. For example, "ROSIE IS CUTE!"

becomes "!ETUC SI EISOR".

In case 2 for the switch

(f) print a blank line, a line with the message:"Part II:" and a blank line.

(g) Print a message:

"Series evaluation: x^n/n! from n=0 to n=n_end.\n" and a blank line.

In the above n! (n factorial)=1*2*...*n for n>0 and 0!=1.

(h) Enter x, a real number and n_end, a large positive integer

from the keyboard and print those values using %g and %d.

(i) In a for-loop evaluate the sum. In addition, print the partial sums

using %16.8e for n=10, 20, 30,.... Print the values of n_end, sum,

and x using %4d, %16.8e, and %g. Finally, print the value of

exp(x) using %g for x and %16.8e for exp(x).

I tried to do part one and i think i got most of it but it doesnt work when i do the a.out. any suggestions?

#include <stdio.h>

#include <math.h>

int main(void)

{

int menu, n, n_end, length;

char message[111];

printf("\nHomework 4:\n\n");

printf("There are two parts: part 1 and part 2.\n");

printf("Enter the part number to execute (1 or 2):");

scanf("%d", &menu);

switch(menu){

case 1:

printf("Part I:\n\n");

printf("\nEnter a text message:");

gets(text);

printf("echo: %s\n", text);

length = (int)strlen(text);

printf("There are %d characters.\n", length);

for(k=length-1; k>=0; k--) printf("%c", text[k]);

printf("\n");

printf("\nPart II:\n\n");

}

}

Edited by flamehead144
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.