1. #include <stdio.h>
2. int main()
3. {
4. a = 10;
5. printf("The value of a is : %d", a);
6. return 0;
7. }
Syntax error
Write c program to compute factorial of 5
Expected outcome:
factorial of 5 = 120
1. #include <stdio.h>
2. int main()
3. {
4. int a=2;
5. int b=2/0;
6. printf("The value of b is : %d", b);
7. return 0;
8. }
Run time error / Division by zero
Or Floating point exception
Write c program 42
Output: 16
#include <stdio.h>
2. int Main()
3. {
4. int a=78;
5. printf("The value of a is : %d", a);
6. return 0;
7. }
Linker error
Write user defined function sum of two numbers
E.g sum(2,5)
Output:7
1. #include <stdio.h>
2. int main()
3. {
4. int sum=0;
5. int k=1;
6. for(int i=1;i<=10;i++);
7. {
8. sum=sum+k;
9. k++;
10. }
11. printf("The value of sum is %d", sum);
12. return 0;
13. }
Logical error
C program to print KLSBCA 5 times
KLSBCA
KLSBCA
KLSBCA
KLSBCA
KLSBCA
1. #include <stdio.h>
2. int main()
3. {
4. int a,b,c;
5. a=2;
6. b=3;
7. c=1;
8. a+b=c;
9. return 0;
10. }
Semantic error
C program generate the Nth Fibonacci number
E.g. n=7
Output:
fibonacci:
0
1
1
2
3
5
8
13