Category: 2nd Semester
DCCN 2017 Solution
2018 1.Why there is bandwidth wastage in FDM? 2018 Ans: Due to the use of guard band in FDM, there is a bandwidth wastage as it uses the bandwidth of FDM. 2.Which layer is responsible for name recognition and security? 2018 Ans: For name recognition and security application layer and presentation layer are responsible […]
Continue ReadingDCCN 2015 Solution
1.How LAN is different form WAN.2015 2015Â (8)
Continue ReadingDCCN 2013 Solution
2013 (2 B)
Continue ReadingC programming 2012
Year 2012 Q.No 3 a)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include<stdio.h> #include<stdlib.h> int main() { float *p; int n,i; float g; printf("How many float number you want to enter? "); scanf("%d",&n); p=(float*)malloc(n*sizeof(float)); printf("Enter %d float numbers ",n); for(i=0;i<n;i++) scanf("%f",&p[i]); for(i=0;i<n-1;i++) { if(p[i]>p[i+1]) { g=p[i]; } else { g=p[i+1]; } } printf("greatest number is %f",g); return 0; } |
b)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#include<stdio.h> #include<stdlib.h> int main() { float *num; int n,i,j; float a; printf("How many float number you want to enter? "); scanf("%d",&n); num=(float*)malloc(n*sizeof(float)); printf("Enter %d float numbers ",n); for(i=0;i<n;i++) scanf("%f",&num[i]); for (i = 0; i < n; ++i) { for (j = i + 1; j < n; ++j) { if (num[i] < num[j]) { a = num[i]; num[i] = num[j]; num[j] = a; } } } printf("Displaying in descending order\n"); for(i=0;i<n;i++) { printf("%f\n",num[i]); } return 0; } |
Q.No 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include<stdio.h> #include<stdlib.h> int main() { float *num; FILE *fp; int n,i,j; float a,sum,avg; printf("How many float number you want to enter? "); scanf("%d",&n); num=(float*)malloc(n*sizeof(float)); printf("Enter %d float numbers ",n); for(i=0;i<n;i++) scanf("%f",&num[i]); fp=fopen("data.tu","w"); for(i=0;i<n;i++) { sum=sum+num[i]; } avg=sum/n; fprintf(fp,"Sum = %f\n",sum); fprintf(fp,"Avg = %f\n",avg); fclose(fp); return 0; } |
Q.No 4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include<stdio.h> int main() { int i,j; for(i=1;i<=5;i++) { printf("\n"); for(j=1;j<=5;j++) { if(i<=j) printf("%c",'c'); else printf(" "); printf(" "); } } return 0; } |
Q.No .5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include<stdio.h> int main() { int a[15],i,sum=0; float b; printf("Enter 15 integers"); for(i=0;i<15;i++) scanf("%d",&a[i]); for(i=0;i<15;i++) { sum=sum+a[i]; } b=sum/15; printf("Average %f",b); return 0; } |
Q.No 6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#include<stdio.h> struct cattle { int cid; char name[20]; int age; float weight; }; int main() { struct cattle a[28]; int i,sum=0; double avg; for(i=0;i<28;i++) { printf("%d record is\n ",i+1); printf("Enter id "); scanf("%d",&a[i].cid); printf("Enter name "); scanf("%s",a[i].name); printf("Enter age "); scanf("%d",&a[i].age); printf("Enter weight "); scanf("%f",&a[i].weight); } for(i=0;i<28;i++) sum=sum+a[i].weight; avg=sum/28; printf("Avg = %f",avg); return 0; } |
C programming 2013
2013 Q.no 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
#include<stdio.h> int min(int a[],int n) //Returns minimum element in array { int i,minn=a[0]; for(i=0;i<n;i++) { if(a[i]<minn) minn=a[i]; } return minn; } int max(int a[],int n) //Returns maximum element in array { int i,maxx=a[0]; for(i=0;i<n;i++) { if(a[i]>maxx) maxx=a[i]; } return maxx; } void main() { int n,i,a[n],j,count=0,min_element,max_element,pov=0,neg=0,cou=0,small; printf("Enter how many number to enter "); scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } small=min(a,n); Printf("smallest number is %d",small); min_element=min(a,n); max_element=max(a,n); for(i=min_element;i<max_element;i++) //Run loop from min element to max element { //and get count of each element in array as usual. count=0; for(j=0;j<n;j++) { if(a[j]==i) count++; } if(count) printf("Count of %d is %d\n",i,count); } for(i=0;i<n;i++) { if(i<0) { neg=neg+a[i]; cou++; } else { pov=pov+a[i]; } } printf("Sum of positive number = %d\nSum of negative number = %d\n",pov,neg); for(i=0;i<n;i++) { if(a[i]%2==0) { cou++; } } printf("Total no of even elements = %d",cou); } |
Q.no. 4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#include<stdio.h> #include<string.h> int main() { int n,i; int id[n]; char name[n][20],oname[n][20],occ[n][20]; printf("Enter number of input to be entered"); scanf("%d",&n); for(i=0;i<n;i++) { printf("Enter id "); scanf("%d",&id[i]); printf("Enter name "); scanf("%s",name[i]); printf("Enter office name "); scanf("%s",oname[i]); printf("Enter occupation "); gets(occ[i]); } for(i=0;i<n;i++) { if(strcmp(oname[i],"Nepal Bank")==0 && strcmp(occ[i],"manager")==0) printf("%s\t %d\t %s\t %s\t",name[i],id[i],oname[i],occ[i]); } } |
Q.no 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
#include<stdio.h> int min(int a[],int n) //Returns minimum rainfall month { int i,minn=a[0]; for(i=0;i<n;i++) { if(a[i]<minn) minn=i; } return minn; } int max(int a[],int n) //Returns maximum rainfall month { int i,maxx=a[0]; for(i=0;i<n;i++) { if(a[i]>maxx) maxx=i; } return maxx; } void result(int a) { switch(a) { case 1: printf("Baisakh\n"); break; case 2: printf("Jestha\n"); break; case 3: printf("Ashad\n"); break; case 4: printf("Shrawan\n"); break; case 5: printf("Bhadoh\n"); break; case 6: printf("Ashosh\n"); break; case 7: printf("Kartik\n"); break; case 8: printf("mangsir\n"); break; case 9: printf("poush\n"); break; case 10: printf("magh\n"); break; case 11: printf("falgun\n"); break; case 12: printf("chaitra\n"); } } void main() { int n[12],i,total; float avg; for(i=0;i<12;i++) { printf("Enter total no of rainfall for %d month\n",i+1); scanf("%d",&n[i]); total=total+n[i]; } avg=total/12; printf("Average = %f\n",avg); for(i=0;i<12;i++) { if(max(n,12)==i) { printf("month with highest rainfall is "); result(i+1); } if(min(n,12)==i) { printf("Month with lowest rainfall is "); result(i); } } } |