Beginning C Programming For Engineers (CSCI-1190)
Beginning C Programming For Engineers (CSCI-1190)
Engineers (CSCI-1190)
Memory
Instructions
+
Data
LOAD A
Assembly Languages ADD B
STORE C
C libaray
9. printf("a+b=%f\n",a+b);
10. printf("a-b=%f\n",a-b);
11. printf("a*b=%f\n",a*b);
12. printf("a/b=%f\n",a/b);
13.}
Assignment
1. /* Arithmetic operators */
2. #include <stdio.h>
3.
4. int main()
5. {
6. int a,c;
7. int b=4;
8. a=3;
9. c=a+b;
10. printf(“Sum: %d + %d -> %d\n”,a,b,c);
11. a++;b--;
12. prinf(“Now a=%d and b=%d\n”,a,b);
13. return 0;
14.}
In-Class Exercise 1-2
• Write a program to calculate the average
of three floating point numbers, namely
2.3, 3.4, 4.5.
• Using scanf function
• Using assignment