Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Create two variables:
- myint /* stores an integer use - int to create this variable*/
- mychar /* stores a character value – use char to create this variable */
- 2. Use an assignment statement to assign the value 5 to myint.
- Example: newint = 7; would assign the value 7 to the variable newint.
- 3. Use an assignment statement to assign the value ‘a’ to mychar. Remember that we use single quote
- marks when we are dealing with individual characters. When we start using strings they are enclosed in
- double quote marks.
- 4. Output the value of myint in a line of text that tells the user this is the integer you input. End the line
- with a NL character. See below.
- 5. Output the value of mychar in a line of text that tells the user this is the character you inputCOSC-1420 C Programming
- L03a Sequence (Program)
- Fall 2013
- Always end your last output (printf) with a NL character ‘\n’ to force any following text to the next line
- on the screen.
- Example: printf(“%c\n”, newchar);
- Notice that the NL character goes in the descriptor, not the line of text (or other items) to be displayed.
- 6. Use a return statement to end your program.
- Be sure you compile and run your C program.
- myint /* Hello World! */
- mychar='a'
- newint=5
- #include<stdio.h>
- int main(void)
- {
- printf(“c\n”, newchar);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement