









































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A list of 29 programming exercises in C language, covering topics such as finding prime numbers, calculating factorial, printing Fibonacci series, and more. Each exercise includes a flowchart, algorithm, and code. useful for students learning C programming and looking for practice exercises.
Typology: Study notes
1 / 81
This page cannot be seen from the preview
Don't miss anything!










































































Sr no. Questions Page no.
d). 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
Q.1 Write a program in c to find the division of student. Ans. Algorithm:- ● Start ● input percentage ● If per >100 invalid percentage ● If Per >=60 Ist division ● If per 50-60 2 nd division ● If Per less than 40 fail ● stop Flowchart:-
#include<stdio.h> #include<conio.h> Void main() { Int per; Clrscr(); Printf(“Enter percentage of student”); Scanf(“%d”,&per); If(per>100) { Printf(“\n invalid percent”); } else if(per>=60) { Printf(“\n first division”); } else if(per<60&&per>=50) { printf(“second division”); } else if(per<50&&per>=40) { printf(“\m third division”); } else {
BCA C Assignment Solutions- MasterProgramming.in Q.2 Write a program in c to find prime number or not. Ans. Flowchart:- False True True false True
Algorithm:- ● Start ● Read number ● i= ● while(i<n) ● if(n%i==0) ● f= ● if(f==1) then print not prime ● else print prime ● end Code:- #include<stdio.h> #include<conio.h> void main() { int n,i,f; f=0; printf("Enter a number"); scanf("%d",&n); i=2; while(i<n) { if(n%i==0) { f=1; break; }
BCA C Language Assignment Solutions- MasterProgramming.in Q.3 Write a program in c to find the leap year. Ans. Algorithm:- ● start ● year ● if(year%4==0) then leap year ● else not leap year ● stop flowchart:- false True
Code:- #include<stdio.h> #include<conio.h> int main() { int year; clrscr(); printf("enter the year :"); scanf("%d",&year); if(year%4==0) { printf("the year %d is leap year",year); } else { printf("the year %d is not leap year",year); } return 0; }
Q.4 Write a progran to calculate factorial of a number. Ans. Flowchart:- false True true Algorithm:- ● start ● read n ● if(n>0) then f= ● if(n==1) then f=f*n and n=n+
● write fact -stop ● else error ● stop Code:- #include<stdio.h> #include<conio.h> long int facto(int n) { if(n==1) { return 1; } else return n*facto(n-1); } void main() { long int f; int num; printf("Enter any number :"); scanf("%d",&num); if(num>0) { f=facto(num); printf("factorial is %d",f); } else
BCA C Language Assignment Solutions- MasterProgramming.in Q. 5 Write a program in c to calculate power using recursion. Ans. #include<stdio.h> #include<conio.h> long int power(int a,int b) { Long int s=1; Int I; If(b==0) { return 0; } for(i=1;i<=b;i++) { s=s*a; } return s; } Void main() { long int p; int c,d; printf(“Enter any two number\n”);
scanf(“%d%d”,&c,&d); p=power(c,d); printf(“\n power is %d”,p); getch(); } Output:-
#include<stdio.h> #include<conio.h> Void main() { Int n,r; Clrscr(); Printf(“Enter a number:”); Scanf(“%d”,&n); r=n%2; if(r==0) { Printf(“Even number”); } else { Printf(“odd number”); } getch(); } Output:-
Q.7 Write a program in c to print fabonnaci series. Ans. Flowchart:- No Yes