Homework Help 2 question.

Hey guys, I need help with two question for my homework on beginners class. I'm using Dev c++ program.

1a- Rewrite the Hello world example in your Dev-C++ compiler. Include your name, Class, Date and
Assignment Name right at the top before the header files.

/************************/
/***Your Name, Last name***/
/*******CECS 121-01*******/
/**Introductory Assignment**/
/**********Date**********/
/************************/
Note that Failure to do this will reduce your grade.
1b - Add your Name, Class, Assignment number and Date to the printf statement, so that your
program shows all these info along with the Hello World sentence.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #include<stdio.h>
#include<conio.h>

int main()

{printf ("/************************/");

printf ("/***First, Last***/");

printf ("/*******CECS*******/");

printf ("/**Assignment 1**/");

printf ("/**********01/15/2014**********/");

printf ("/************************/");
getch();

return (0);

}
You forgot to add Hello World!
I know, but when i want to compile and run, all of the line is currently in one line. how do i fix that problem? I want each line to be separate from one another.
One option is to use puts instead of printf, since you're just printing some strings:
http://www.cplusplus.com/reference/cstdio/puts/

You can also use \n within a string to represent a newline character. For instance:
printf("Hello world!\nThis is on a new line");
which will print
Hello world!
This is on a new line

Also, is this a C class or a C++ class?
Given that you're using printf, I'm assuming that this is for C, but if it is C++, then I would recommend using the standard C++ streams (e.g. std::cout) rather than C-style I/O (printf, etc.)
closed account (EwCiz8AR)
may be its will help you


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include<stdio.h>
#include<conio.h>

int main()

{printf ("/************************/\n");

printf ("/***First, Last***/\n");

printf ("/*******CECS*******/\n");

printf ("/**Assignment 1**/\n");

printf ("/**********01/15/2014**********/\n");

printf ("/************************/\n");
getch();

return (0);

}
Topic archived. No new replies allowed.