CS25C01 – Computer Programming: C (Regulation 2025)
Question Bank with Answers
UNIT 1 – BASICS OF C PROGRAMMING
A) 2-Mark Questions
1. What is a C program?
2. List any two features of C.
3. Define a variable with an example.
4. What is a constant? Give an example.
5. Differentiate between int and float.
6. What is a header file? Give an example.
7. Explain the use of printf() and scanf().
8. What is the difference between = and ==?
9. Define an operator in C. List two arithmetic operators.
10. Define keywords in C.
11. What is the purpose of main() function?
12. What is a comment? Give syntax.
13. Explain preprocessor directives.
14. Define expression in C with example.
15. What is type casting in C?
16. Differentiate while and do-while loops.
17. What is the use of break and continue statements?
18. Define array with example.
19. What is a string in C?
20. Define a function in C.
B) Big Questions
1. Explain the structure of a C program with an example.
#include <stdio.h>
int add(int a,int b){ return a+b; }
int main(){
int x=2,y=3;
printf("Sum=%d\n", add(x,y));
return 0;
}
2. Write a program to check whether a number is prime or not.
#include <stdio.h>
int main(){
int n,i,flag=1;
scanf("%d",&n);
if(n<=1) flag=0;
for(i=2;i*i<=n && flag;i++) if(n%i==0) flag=0;
if(flag) printf("Prime\n"); else printf("Not prime\n");
return 0;
}
3. Write a program to find factorial of a number.
#include <stdio.h>
long fact(long n){ if(n<=1) return 1; return n*fact(n-1); }
int main(){ int n; scanf("%d",&n); printf("%ld\n", fact(n)); return 0; }
4. Explain data types in C with examples.
Basic types: int, char, float, double. Example: int a=5; char ch='A'; float f=3.14; double d=3.14159;
5. Write a program to display first n natural numbers using while loop.
#include <stdio.h>
int main(){ int n,i=1; scanf("%d",&n); while(i<=n){ printf("%d ",i); i++; } return 0; }
6. Write a program to swap two numbers using a temporary variable.
#include <stdio.h>
int main(){ int a=5,b=10,t; t=a;a=b;b=t; printf("a=%d b=%d",a,b); return 0;}
7. Explain for, while and do-while loops with examples.
For: for(i=0;i<3;i++){ printf("%d",i); } While: i=0; while(i<3){ printf("%d",i); i++; } Do-while: i=0; do{ printf("%d",i); i++;
} while(i<3);
8. Write a program to print Fibonacci series up to n terms.
#include <stdio.h>
int main(){ int n,t1=0,t2=1,next,i; scanf("%d",&n); for(i=1;i<=n;i++){ printf("%d ",t1); next=t1+t2;t1
UNIT 2 – UNIT 2 CONTENT PLACEHOLDER
A) 2-Mark Questions
1. What is a C program?
2. List any two features of C.
3. Define a variable with an example.
4. What is a constant? Give an example.
5. Differentiate between int and float.
6. What is a header file? Give an example.
7. Explain the use of printf() and scanf().
8. What is the difference between = and ==?
9. Define an operator in C. List two arithmetic operators.
10. Define keywords in C.
11. What is the purpose of main() function?
12. What is a comment? Give syntax.
13. Explain preprocessor directives.
14. Define expression in C with example.
15. What is type casting in C?
16. Differentiate while and do-while loops.
17. What is the use of break and continue statements?
18. Define array with example.
19. What is a string in C?
20. Define a function in C.
B) Big Questions
1. Explain the structure of a C program with an example.
#include <stdio.h>
int add(int a,int b){ return a+b; }
int main(){
int x=2,y=3;
printf("Sum=%d\n", add(x,y));
return 0;
}
2. Write a program to check whether a number is prime or not.
#include <stdio.h>
int main(){
int n,i,flag=1;
scanf("%d",&n);
if(n<=1) flag=0;
for(i=2;i*i<=n && flag;i++) if(n%i==0) flag=0;
if(flag) printf("Prime\n"); else printf("Not prime\n");
return 0;
}
3. Write a program to find factorial of a number.
#include <stdio.h>
long fact(long n){ if(n<=1) return 1; return n*fact(n-1); }
int main(){ int n; scanf("%d",&n); printf("%ld\n", fact(n)); return 0; }
4. Explain data types in C with examples.
Basic types: int, char, float, double. Example: int a=5; char ch='A'; float f=3.14; double d=3.14159;
5. Write a program to display first n natural numbers using while loop.
#include <stdio.h>
int main(){ int n,i=1; scanf("%d",&n); while(i<=n){ printf("%d ",i); i++; } return 0; }
6. Write a program to swap two numbers using a temporary variable.
#include <stdio.h>
int main(){ int a=5,b=10,t; t=a;a=b;b=t; printf("a=%d b=%d",a,b); return 0;}
7. Explain for, while and do-while loops with examples.
For: for(i=0;i<3;i++){ printf("%d",i); } While: i=0; while(i<3){ printf("%d",i); i++; } Do-while: i=0; do{ printf("%d",i); i++;
} while(i<3);
8. Write a program to print Fibonacci series up to n terms.
#include <stdio.h>
int main(){ int n,t1=0,t2=1,next,i; scanf("%d",&n); for(i=1;i<=n;i++){ printf("%d ",t1); next=t1+t2;t1
UNIT 3 – UNIT 3 CONTENT PLACEHOLDER
A) 2-Mark Questions
1. What is a C program?
2. List any two features of C.
3. Define a variable with an example.
4. What is a constant? Give an example.
5. Differentiate between int and float.
6. What is a header file? Give an example.
7. Explain the use of printf() and scanf().
8. What is the difference between = and ==?
9. Define an operator in C. List two arithmetic operators.
10. Define keywords in C.
11. What is the purpose of main() function?
12. What is a comment? Give syntax.
13. Explain preprocessor directives.
14. Define expression in C with example.
15. What is type casting in C?
16. Differentiate while and do-while loops.
17. What is the use of break and continue statements?
18. Define array with example.
19. What is a string in C?
20. Define a function in C.
B) Big Questions
1. Explain the structure of a C program with an example.
#include <stdio.h>
int add(int a,int b){ return a+b; }
int main(){
int x=2,y=3;
printf("Sum=%d\n", add(x,y));
return 0;
}
2. Write a program to check whether a number is prime or not.
#include <stdio.h>
int main(){
int n,i,flag=1;
scanf("%d",&n);
if(n<=1) flag=0;
for(i=2;i*i<=n && flag;i++) if(n%i==0) flag=0;
if(flag) printf("Prime\n"); else printf("Not prime\n");
return 0;
}
3. Write a program to find factorial of a number.
#include <stdio.h>
long fact(long n){ if(n<=1) return 1; return n*fact(n-1); }
int main(){ int n; scanf("%d",&n); printf("%ld\n", fact(n)); return 0; }
4. Explain data types in C with examples.
Basic types: int, char, float, double. Example: int a=5; char ch='A'; float f=3.14; double d=3.14159;
5. Write a program to display first n natural numbers using while loop.
#include <stdio.h>
int main(){ int n,i=1; scanf("%d",&n); while(i<=n){ printf("%d ",i); i++; } return 0; }
6. Write a program to swap two numbers using a temporary variable.
#include <stdio.h>
int main(){ int a=5,b=10,t; t=a;a=b;b=t; printf("a=%d b=%d",a,b); return 0;}
7. Explain for, while and do-while loops with examples.
For: for(i=0;i<3;i++){ printf("%d",i); } While: i=0; while(i<3){ printf("%d",i); i++; } Do-while: i=0; do{ printf("%d",i); i++;
} while(i<3);
8. Write a program to print Fibonacci series up to n terms.
#include <stdio.h>
int main(){ int n,t1=0,t2=1,next,i; scanf("%d",&n); for(i=1;i<=n;i++){ printf("%d ",t1); next=t1+t2;t1
UNIT 4 – UNIT 4 CONTENT PLACEHOLDER
A) 2-Mark Questions
1. What is a C program?
2. List any two features of C.
3. Define a variable with an example.
4. What is a constant? Give an example.
5. Differentiate between int and float.
6. What is a header file? Give an example.
7. Explain the use of printf() and scanf().
8. What is the difference between = and ==?
9. Define an operator in C. List two arithmetic operators.
10. Define keywords in C.
11. What is the purpose of main() function?
12. What is a comment? Give syntax.
13. Explain preprocessor directives.
14. Define expression in C with example.
15. What is type casting in C?
16. Differentiate while and do-while loops.
17. What is the use of break and continue statements?
18. Define array with example.
19. What is a string in C?
20. Define a function in C.
B) Big Questions
1. Explain the structure of a C program with an example.
#include <stdio.h>
int add(int a,int b){ return a+b; }
int main(){
int x=2,y=3;
printf("Sum=%d\n", add(x,y));
return 0;
}
2. Write a program to check whether a number is prime or not.
#include <stdio.h>
int main(){
int n,i,flag=1;
scanf("%d",&n);
if(n<=1) flag=0;
for(i=2;i*i<=n && flag;i++) if(n%i==0) flag=0;
if(flag) printf("Prime\n"); else printf("Not prime\n");
return 0;
}
3. Write a program to find factorial of a number.
#include <stdio.h>
long fact(long n){ if(n<=1) return 1; return n*fact(n-1); }
int main(){ int n; scanf("%d",&n); printf("%ld\n", fact(n)); return 0; }
4. Explain data types in C with examples.
Basic types: int, char, float, double. Example: int a=5; char ch='A'; float f=3.14; double d=3.14159;
5. Write a program to display first n natural numbers using while loop.
#include <stdio.h>
int main(){ int n,i=1; scanf("%d",&n); while(i<=n){ printf("%d ",i); i++; } return 0; }
6. Write a program to swap two numbers using a temporary variable.
#include <stdio.h>
int main(){ int a=5,b=10,t; t=a;a=b;b=t; printf("a=%d b=%d",a,b); return 0;}
7. Explain for, while and do-while loops with examples.
For: for(i=0;i<3;i++){ printf("%d",i); } While: i=0; while(i<3){ printf("%d",i); i++; } Do-while: i=0; do{ printf("%d",i); i++;
} while(i<3);
8. Write a program to print Fibonacci series up to n terms.
#include <stdio.h>
int main(){ int n,t1=0,t2=1,next,i; scanf("%d",&n); for(i=1;i<=n;i++){ printf("%d ",t1); next=t1+t2;t1
UNIT 5 – UNIT 5 CONTENT PLACEHOLDER
A) 2-Mark Questions
1. What is a C program?
2. List any two features of C.
3. Define a variable with an example.
4. What is a constant? Give an example.
5. Differentiate between int and float.
6. What is a header file? Give an example.
7. Explain the use of printf() and scanf().
8. What is the difference between = and ==?
9. Define an operator in C. List two arithmetic operators.
10. Define keywords in C.
11. What is the purpose of main() function?
12. What is a comment? Give syntax.
13. Explain preprocessor directives.
14. Define expression in C with example.
15. What is type casting in C?
16. Differentiate while and do-while loops.
17. What is the use of break and continue statements?
18. Define array with example.
19. What is a string in C?
20. Define a function in C.
B) Big Questions
1. Explain the structure of a C program with an example.
#include <stdio.h>
int add(int a,int b){ return a+b; }
int main(){
int x=2,y=3;
printf("Sum=%d\n", add(x,y));
return 0;
}
2. Write a program to check whether a number is prime or not.
#include <stdio.h>
int main(){
int n,i,flag=1;
scanf("%d",&n);
if(n<=1) flag=0;
for(i=2;i*i<=n && flag;i++) if(n%i==0) flag=0;
if(flag) printf("Prime\n"); else printf("Not prime\n");
return 0;
}
3. Write a program to find factorial of a number.
#include <stdio.h>
long fact(long n){ if(n<=1) return 1; return n*fact(n-1); }
int main(){ int n; scanf("%d",&n); printf("%ld\n", fact(n)); return 0; }
4. Explain data types in C with examples.
Basic types: int, char, float, double. Example: int a=5; char ch='A'; float f=3.14; double d=3.14159;
5. Write a program to display first n natural numbers using while loop.
#include <stdio.h>
int main(){ int n,i=1; scanf("%d",&n); while(i<=n){ printf("%d ",i); i++; } return 0; }
6. Write a program to swap two numbers using a temporary variable.
#include <stdio.h>
int main(){ int a=5,b=10,t; t=a;a=b;b=t; printf("a=%d b=%d",a,b); return 0;}
7. Explain for, while and do-while loops with examples.
For: for(i=0;i<3;i++){ printf("%d",i); } While: i=0; while(i<3){ printf("%d",i); i++; } Do-while: i=0; do{ printf("%d",i); i++;
} while(i<3);
8. Write a program to print Fibonacci series up to n terms.
#include <stdio.h>
int main(){ int n,t1=0,t2=1,next,i; scanf("%d",&n); for(i=1;i<=n;i++){ printf("%d ",t1); next=t1+t2;t1