Advertisement
oxb

C assignment

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