Bca Solved Assignment BCSL 021 C Language Programming Lab
Bca Solved Assignment BCSL 021 C Language Programming Lab
http://www.ignouassignmentguru.com
Course Code : BCSL-021
Course Title : C Language Programming
Assignment Number : BCA(2)/L-021/Assignment/16-17
Maximum Marks : 50 Weightage : 25%
Last Dates for Submission : 15thOctober, 2016 (For July 2016 Session)
15th April, 2017 (For January 2017 Session)
Course Code: BCSL-021
Ans:
#include<stdio.h>
long factorial(int);
int main()
{
int i, n, c;
scanf("%d",&n);
long factorial(int n)
1
{
int c; IGNOU ASSIGNMENT GURU Page-
long result = 1;
int main()
{
/IGNOUASSIGNMENTGURU
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
float radius;
float surface_area, volume;
/IGNOUASSIGNMENTGURU
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
those students who have obtained GPA greater than 9.0 by 25% of the original fees, 10%
fee concession if GPA is between 8.0 and 8.9 and 5% concession if the GPA is between 7.5
and 7.9. Display all the records before and after updation. (5 Marks)
Ans:
#include<stdio.h>
#define SIZE 50
struct student
{
char name[30];
int rollno;
int gpa,fee;
};
3
IGNOU ASSIGNMENT GURU Page-
for (i = 0; i < n; i++)
{
printf("\nEnter details name, rollno,gpa,fee");
scanf("%s", &st[i].name);
scanf("%d", &st[i].rollno);
scanf("%d", &st[i].gpa);
scanf("%d", &st[i].fee);
}
Printf(“\nPrint Before update\n”)
for (i = 0; i < n; i++)
{
/IGNOUASSIGNMENTGURU
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
printf("GPA=%d", &st[i].gpa);
printf("fee=%d", &st[i].fee);
calcfee(st[i]);
Printf(update data:\n”)
getch();
}
5. Using pointers, write a function that receives a string and a character as argument.
Delete all occurrences of this character in the string. The function should return corrected
string with no holes/spaces. (5 Marks)
Ans:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main() {
char str[10];
char ch;
del(str, ch);
getch();
} 4
IGNOU ASSIGNMENT GURU Page-
size = strlen(str);
/IGNOUASSIGNMENTGURU
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
}
}
str1[j] = '\0';
/IGNOUASSIGNMENTGURU
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
int gr,i;
printf("Enter Grade 1 to 5:");
scanf("%d",&gr);
if(gr>=1||gr<=5)
{
for(i=0;i<=4;i++)
{
if(inn[i].grade==gr)
printf("Hotel Name: %s\nAddress:%s\nGrade:%d\nAverage Room charge:%d\n\
Number of Rooms:%d",inn[i].name,inn[i].add,inn[i].grade,inn[i].arc,inn[i].rooms);
}
}
else
printf("Wrong grade input!");
}
void out()
{
int ch,i=0;
printf("Enter the Room charges not greater than 6000:");
scanf("%d",&ch);
while(i<5)
{
if(inn[i].arc<ch)
printf("Hotel Name: %s\nAddress:%s\nGrade:%d\nAverage Room charge:%d\n\
Number of Rooms:%d\n",inn[i].name,inn[i].add,inn[i].grade,inn[i].arc,inn[i].rooms);
i++;
}}
do
{
x=fgetc(p);
putchar(x);
fputc(x,y);
}while(x!=eof());
getch();
}
8. Write an interactive C program to reverse the first n characters in a file.:
Ans:
#include <stdio.h>
/IGNOUASSIGNMENTGURU
BCA & MCA (IGNOU)
http://www.ignouassignmentguru.com
#include <conio.h>
#include <string.h>
#include <process.h>
if(argc!=3)
{
puts("Improper number of arguments.");
exit(0);
}
fp = fopen(argv[1],"r");
if(fp == NULL)
{
puts("File cannot be opened.");
exit(0);
}
k=*argv[2]-48;
n = fread(a,1,k,fp);
a[n]='\0';
len=strlen(a);
for(i=len-1;i>=0;i--)
{
s[j]=a[i];
printf("%c",s[j]);
j=j+1;
} 7
IGNOU ASSIGNMENT GURU Page-
s[j+1]='\0';
getch();
}/
/IGNOUASSIGNMENTGURU