NEWS & UPDATES >> BCA BCSP064 Synopsis & Project Work Started for DEC 2017, IGNOU MCA MCSP060 Synopsis Work Started for DEC 2017, CONTACT 4 IGNOU Mini Project

BCSL-021 SOLVED ASSIGNMENT 2016-2017 IGNOU BCA 2nd SEM

1. Write a C program to generate Pascal's triangle.

Ans:

#include<stdio.h> long factorial(int); int main()

{

int i, n, c;

printf("How many rows you want to show in pascal triangle?\n");

scanf("%d",&n);

for ( i = 0 ; i < n ; i++ )

{

for ( c = 0 ; c <= ( n ­ i ­ 2 ) ; c++ ) printf(" ");

for( c = 0 ; c <= i ; c++ )

printf("%ld ",factorial(i)/(factorial(c)*factorial(i­c))); printf("\n");

}

return 0;

}

long factorial(int n)

{

int c;

long result = 1;

for( c = 1 ; c <= n ; c++ ) result = result*c; return ( result );


}


2.
Write a C Program to find the surface area and the volume of a sphere. (Surface Area = 4 π r2 and Volume = 4/ 3 π r3 )

#include <stdio.h>


#include <math.h>
intmain()
{

floatradius;floatsurface_area,volume;

printf("Enter radius of the sphere : \n");scanf("%f",&radius);

surface_area =4*(22/7)*radius *radius; volume =(4.0/3)*(22/7)*radius *radius *radius;

printf("Surface area of sphere is: %.3f",surface_area);printf("\nVolume of sphere is : %.3f",volume);return0;

}



3.
Write a C program to find whether the given matrix is symmetric or not.

Ans:

#include<conio.h>

#include<stdio.h> void main()

{

int a[10][10],i,j,m; clrscr();

printf("Enter order of square matrix: "); scanf("%d",&m);

for(i=1;i<=m;i++)

{

for(j=1;j<=m;j++)

{

printf("Enter value of a[%d][%d]: ",i,j); scanf("%d",&a[i][j]);

}

}

for(i=1;i<=m;i++)

{

for(j=1;j<=m;j++)

{

if(a[i][j]!=a[j][i])

{

printf("\n\nMatrix is not symmetric"); getch();
exit(0);

}

}

}

printf("\n\nMatrix is symmetric"); getch();


}




4.
Write a interactive C program to create records of 15 students, where each record has fields name, rollno, GPA and fees. Write a function calcfee ( ) to reduce the fees of 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.

#include<stdio.h> #define SIZE 50

struct student

{

char name[30]; int rollno;

int gpa,fee;


void calcfee(struct student st[])

{

for (i = 0; i < n; i++)

{

if(st[i].gpa>=9.0)

st[i].fee=st[i].fee­(st[i].fee*0.25);

else if(s[i]t.gpa<=8.9 && st[i].gpa<8.0)

{

St[i].fee=st[i].fee­(st[i].fee*0.05); printf("Total Fee=%d",st[i].fee); printf("roll no=%d", &st[i].rollno);

}

}

}

void main()

{

int i, j, max, count, total, n, a[SIZE], ni;




struct student st; clrscr();

printf("Enter how many students: "); scanf("%d", &n);


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++)

{

printf("roll no=%d", &st[i].rollno); printf (“GPA=%d", &st[i].gpa);

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.

Ans:

#include<stdio.h>

#include<conio.h>

#include<string.h>


void del(char str[], char ch);
void main() { char str[10]; char ch;

printf("\nEnter the string : "); gets(str);

printf("\nEnter character which you want to delete : "); scanf("%ch", &ch);

del(str, ch); getch();

}

void del(char str[], char ch) { int i, j = 0;

int size; char ch1; char str1[10];

size = strlen(str);

for (i = 0; i < size; i++) { if (str[i] != ch) {

ch1 = str[i]; str1[j] = ch1; j++;

}

}

str1[j] = '\0';

printf("\n corrected string is : %s", str1);

}




6.
Define a structure that describes a hotel. It should have members that include the name, address, star(5 star, 3 star or 2 star), average room charge and number of rooms. Write a function to perform the following operations:
(i) To print out hotels of a given grade in order of charges.
(ii) To print out hotels with room charges less than a given value.

Ans:

#include <stdio.h> struct hotel
{

char name[20]; char add[20]; int grade;

int arc; int rooms; };

void output(); void out();

struct hotel inn[]={ {"PLAZA","G­99,DELHI",3,4500,50}, {"MYUR","E­45,NOIDA",4,5000,100}, {"RAJDOOT","H­44,DELHI",2,4000,50}, {"SAMRATH","B­75,BOMBAY",5,6000,200}, {"SURYA","A­77,NOIDA",1,3500,150}


void main()

{

int go; clrscr();

printf("Enter 1 for grade search\n"); printf("Enter 2 to search by charge:"); scanf("%d",&go);

switch(go)

{

case 1: output(); break;

case 2: out(); break;

default:printf("Wrong input"); break;

}

getch();

}

void output()

{

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++;

}}




7. Write an interactive C program which copies one file to another.

Ans:
#include<stdio.h> void main()

{

char x; FILE *p,*y; clrscr();

p=fopen("abc.txt","r");

y=fopen("xyz.txt","w");

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. (Note: The file name and n are to be specified on the command line.)

Note: You must execute the program and submit the program logic, sample input and output along with the necessary documentation for these practical questions. Assumptions can be made wherever necessary.


Ans:

#include <stdio.h> #include <conio.h> #include <string.h> #include <process.h>

void main(int argc, char *argv[])

{

char a[15]; char s[20]; char n;

int k; int j=0; int i; int len;

FILE *fp;

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;

}


s[j+1]='\0';
getch();

}

***********************END OF ASSIGNMENT*******************
-----------------------------------------------------------------------------------------
Assignment Solution on process | IGNOU BCA MCA Solved Assignment 2016 2017  Join IGNOU BCA MCA Coaching Class |  Synopsis & Project Support 
Powered by IGNOUFriend | www.ignoufriend.co.in |
ignou bca mca synopsis, ignou class, ignou bca mca project, solved ignou assignment,BCA Coaching Institute in Delhi, MCA Coaching Institute in Delhi, BCA MCA Coaching Institute in Delhi, BCA MCA, Tuation Class in delhi, IGNOU BCA MCA Class, IGNOU BCA MCA Tution,IGNOU Solved Assignment, IGNOU BCA Synopsis , IGNOU MCA Synopsis, ignou bca project, ignou mca project, ignou best coaching in delhi, ignou best coaching in new delhi, ignou best coaching in south delhi, ignou best coaching in north delhi, ignou best coaching in east delhi, ignou best coaching in west delhi
ignou, bca, mca, coaching institute, tution class, bcsp064, mcsp060, cs76, mcs044,bcs011, bcs012, mcs011, mcs012, mcs013, mcs015, bcsl021, bcsl022, mcs014, bcs040, mcs021, mcs023, bcs031, bcsl032, bcsl033, bcsl 034, bcs041, bcs042, mcsl016, bcsl043, bcsl044, bcsl045, bcs051, bcs052, bcs053, bcs054, bcs055, bcsl056, bcsl057, bcsl058, bcs062, mcs022, bcsl063, project
mcsp060, mcse011, mcse004, mcse003, mcsl054, mcs053, mcs052, mcs051, mcsl045, mcs044, mcs043, mcs042, mcs041, mcsl036, mcs035, mcs034, mcs033, mcs032, mcs031, mcsl025, mcs024, mcs023, mcs022, mcs021, mcsl017, mcsl016, mcs015, mcs014, mcs013, mcs012, mcs011
nips institute, nipsar, ignoufriend.in, ignoufriend.co.in, ignouhelp, best coaching institute

No comments:

Post a Comment