OM INSTITUTE OF TECHNOLOGY PVT. LTD. 1. Define a flowchart. Write an algorithm and draw a corresponding flowchart to create a simple multiple choice question (MCQ) examination of 25 questions for 50 marks along with evaluation process too. Ans: Flowchart is a way to represent a programming process in graphical way. A picture or diagram is an essential element to understand the complex problem. In programming, such types of drawings are used for representing a program and its process is known as Flowchart. “It is a pictorial representation of a program”. 2. Compare and contrast the characteristics and/or Organisation of the Write an interactive C program for Q1. #include<stdio.h> 1|Page Valid Upto April2016 OM INSTITUTE OF TECHNOLOGY PVT. LTD. #include<conio.h> main() { charqs[][100]={ {"\n1. OM INSTITUTE OF TECNOLOGY...Students.\n\t (1). IGNOU (2). IP"}, {"\n2. Who is CM of Delhi? \n\t(1). NarenderModi (2). ArvindKej"}, {"\n3. What colour is Grass? \n\t(1). Green (2). Black"}, {"\n4. OIT Located at....\n\t(1). LaxmiNagar (2). Karolbagh"}, {"\n5. Duration of BCA is....\n\t(1). 8 Years (2). 3 Years"}, }; intans[]={1,2,1,1,2}; int choice; int score=0,a=0,t; for(a=0;a<5;a++) { clrscr(); puts(qs[a]); printf("\nEnter the Ans( 1 or 2 )....\n"); scanf("%d",&choice); if(ans[a]==choice) score=score+1; if(a<4) { printf("\nPress enter for select Next Question...\n"); getch(); } else printf("\nGame Over\n"); } printf("\nyour score is=%d",score); getch(); } 2|Page Valid Upto April2016 OM INSTITUTE OF TECHNOLOGY PVT. LTD. 3. Discuss the significance of BITWISE operators in C programming language. Also, write an interactive C program to illustrate them. Bitwise operator Operator Description & Binary AND Operator copies a bit to the result if it exists in both operands. | Binary OR Operator copies a bit if it exists in either operand. ^ Binary XOR Operator copies the bit if it is set in one operand but not both. ~ Binary Ones Complement Operator is unary and has the effect of 'flipping' bits. << Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. >> Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. Example Try the following example to understand all the bitwise operators available in C programming language: #include <stdio.h> main() { unsignedint a = 50; unsignedint b = 11; int c = 0; c = a & b; printf("Value of c is %d\n", c ); c = a | b; printf("Value of c is %d\n", c ); c = a ^ b; printf(" Value of c is %d\n", c ); c = ~a; printf("Value of c is %d\n", c ); c = a << 2; printf("Value of c is %d\n", c ); c = a >> 2; printf("Value of c is %d\n", c ); } 3|Page Valid Upto April2016 OM INSTITUTE OF TECHNOLOGY PVT. LTD. 4. Define an array. Write an interactive C program to take two single dimensional arrays of integers and merge them into a single dimensional array, excluding the common elements of both the arrays. Ans: In computer programming languages, an array is a group of objects with the same attributes that can be addressed individually, using such techniques as subscripting. Memory representation of array- it allocates 10 bytes memory space for the 5integer value. It allocates contiguous memory location. #include<stdio.h> void sort(int a[]) { inti,j,t; for(i=0;i<=4;i++) { for(j=i;j<=4;j++) { if(a[i]>=a[j]) { t=a[i]; a[i]=a[j]; a[j]=t; } } } } int merge(int a[],int b[],int c[]) { inti=0,j=0,k=0; while(i<5 && j<5) { if(a[i]<b[j]) { c[k]=a[i]; i++; k++; } 4|Page Valid Upto April2016 OM INSTITUTE OF TECHNOLOGY PVT. LTD. else if (a[i]==b[j]) { c[k]=b[j]; i++; j++; k++; } else { c[k]=b[j]; j++; k++; } } while(j<5) { c[k]=b[j]; k++; j++; } while(i<5) { c[k]=a[i]; k++; i++; } return k; } voiddisp(int c[],int size) // to display element of array { inti; for(i=0;i<size;i++) printf(" %d",c[i]); } main() 5|Page Valid Upto April2016 OM INSTITUTE OF TECHNOLOGY PVT. LTD. { int a[5],b[5]; int c[10],i,j,k,s; clrscr(); printf("enter the array first\n"); for(i=0;i<5;i++) { scanf("%d",&a[i]); } printf("enter the array second\n"); for(i=0;i<5;i++) { scanf("%d",&b[i]); } sort(a); sort(b); printf("\nMy first Array:"); disp(a,5); printf("\n\nMy first Array:"); disp(b,5); s=merge(a,b,c); printf("\n\nMerged Array:%d\n",s); disp(c,s); getch(); } 5. Write an interactive C program which illustrates the following concepts: include<stdio.h> void sum() //Function with no arguments and no return value. { 6|Page Valid Upto April2016 OM INSTITUTE OF TECHNOLOGY PVT. LTD. inta,b,c; printf("enter the number"); scanf("%d%d",&a,&b); c=a+b; printf("\nSum=%d",c); } void add(int a, int b) //Function with arguments and no return value. { int c; c=a+b; printf("\nadd=%d",c); } int calculate(int a, int b) //Function with arguments and return value. { int c; c=a+b; return c; } main() { int x; clrscr(); sum(); add(4,5); x=calculate(7,5); printf("\ncalculate=%d",x); getch(); }; 6. Write an interactive C program to manage the assignments at study centres for the first semester courses of MCA (MCS-011, 012, 13, 014, 015, MCSL-016 and MCSL-017). Maximum marks for each assignment is 100 marks and weightage is 25%. Attending the viva-voce at the study centre for each assignment iss percentage in each assignment is 40%. (Note: Use Structures concept). #include<stdio.h> 7|Page Valid Upto April2016 OM INSTITUTE OF TECHNOLOGY PVT. LTD. structstd { intenrol; char Name[15]; int m1,m2,m3,m4,m5,m6,m7; }s; FILE *f1,*f2; void input() { f1=fopen("data1","ab"); printf("\nEnter the Enrol\n"); scanf("%d",&s.enrol); printf("\n MCS-011:Marks obtain out of100 is:"); scanf("%d",&s.m1); printf("\n Enter MCS-012:Marks obtain out of100 is:"); scanf("%d",&s.m2); printf("\n Enter MCS-013:Marks obtain out of100 is:"); scanf("%d",&s.m3); printf("\n Enter MCS-014:Marks obtain out of100 is:"); scanf("%d",&s.m4); printf("\n Enter MCS-015:Marks obtain out of100 is:"); scanf("%d",&s.m5); printf("\n Enter MCSL-016:Marks obtain out of100 is:"); scanf("%d",&s.m6); printf("\n Enter MCSL-017:Marks obtain out of100 is:"); scanf("%d",&s.m7); fwrite(&s,sizeof(s),1,f1); fflush(stdin); fclose(f1); } void output() { f1=fopen("data1","r+b"); fflush(f1); rewind(f1); while(fread(&s,sizeof(s),1,f1)) 8|Page Valid Upto April2016 OM INSTITUTE OF TECHNOLOGY PVT. LTD. { printf("Enrol : %d\n",s.enrol); printf("MCS-011 : %d\n",s.m1); printf("MCS-012 : %d\n",s.m2); printf("MCS-013 : %d\n",s.m3); printf("MCS-014 : %d\n",s.m4); printf("MCS-015 : %d\n",s.m5); printf("MCSL-016: %d\n",s.m6); printf("MCSL-017: %d\n",s.m7); } close(f1); } main() { intch; char cc; do { clrscr(); printf("\n1-for Add"); printf("\n2-for Display"); printf("\n3-for exit"); printf ("\nEnter your choice"); scanf("%d",&ch); switch(ch) { case 1: input(); break; case 2: output(); break; case 3: break; } 9|Page Valid Upto April2016 OM INSTITUTE OF TECHNOLOGY PVT. LTD. printf("\nDo you want to Continue(Y/N)\n"); cc=getche(); }while(cc=='y'|| cc=='Y'); getch(); } 10 | P a g e V a l i d U p t o A p r i l 2 0 1 6