Advertisement
Dido09

Syntax

Feb 27th, 2022 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.  
  5. int a,b;
  6. printf("Enter two numbers: ");
  7. scanf("%d %d", &a, &b);
  8.  
  9. printf("\nSum:%d ", a+b);
  10.  
  11. return 0;
  12. }
  13. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  14. #include <stdio.h>
  15.  
  16. int main() {
  17. int x;
  18. float num;
  19. char text[20];
  20. scanf("%d %f %s", &x, &num, text);
  21.  
  22. //Typing 10 22.5 abcd and then pressing Enter assigns 10 to x, 22.5 to num, and abcd to text.
  23. }
  24. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  25. #include <stdio.h>
  26.  
  27. int main() {
  28. printf("Color: %s, Number: %d, float: %5.2f \n", "red", 42, 3.14159);
  29. /* Color: red, Number: 42, float: 3.14 */
  30.  
  31. printf("Pi = %3.2f \n", 3.14159);
  32. /* Pi = 3.14 */
  33.  
  34. printf("Pi = %8.5f \n", 3.14159);
  35. /* Pi = 3.14159 */
  36.  
  37. printf("Pi = %-8.5f \n", 3.14159);
  38. /* Pi = 3.14159 */
  39.  
  40. printf("There are %d %s in the tree. \n", 22, "apples");
  41. /* There are 22 apples in the tree. */
  42. }
  43. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  44. #include <stdio.h>
  45.  
  46. int main(){
  47.  
  48. int a;
  49. printf("Enter a number: ");
  50. scanf("%d", &a);
  51.  
  52. printf("\nThe number you entered is: %d", a);
  53.  
  54. if (a > 4)
  55. printf("\nThe number is bigger than four");
  56. else
  57. printf("\nThe number is less than four");
  58. return 0;
  59. }
  60. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  61. #include <stdio.h>
  62.  
  63. int SumOfNumbers(int a, int b){
  64. int sum;
  65. sum = a + b;
  66. return sum;
  67. }
  68.  
  69.  
  70. int main(){
  71.  
  72. int a,b;
  73. printf("Enter two numbers: ");
  74. scanf("%d %d", &a, &b);
  75.  
  76. int sum = SumOfNumbers(a,b);
  77. printf("%d\n", sum);
  78.  
  79. return 0;
  80. }
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement