You are on page 1of 11

Q1.

Write an interactive C program which prompts the user with the following
options on the opening menu:
(40 Marks)

1) Study Centre Information


2) Details of the programmes activated in the study Centre
3) Scheduling of theory/practical sessions for BCA programme
4) Academic Councilor Details
5) Assignments submission and viva voce schedule
7) Quit
Enter your choice:
If 1 is entered, prompt the user to enter the study Centre code and know the
details about the study like name of the study Centre, name of the regional
Centre, name of the study center coordinator, programme in-charge details etc.
If 2 is entered, it should give the details of all the programmes those are
activated in the Centre. If 3 is entered, it should give the schedule for the
theory and practical counseling sessions for BCA programme for the current
session. If 4 is entered it should display the details of the academic councilors
associated with respective programmes. If 5 is entered it should display the
assignments submission and viva voce schedule for the current session. If the
user enters any letters or numbers other than the choice, redisplay the prompt.
All output should go to the terminal and all input should come from the
keyboard.

Q1.Answer: (without the use of data/file handling)


/*----------------------------------------------------"Important Note"--------------------------------------------------------*/
/* -> THIS PROGRAM DOES NOT STORE DATA INTO FILES |IT ONLY STORES DATA WHILE EXECUTION.
-> Please execute and terminate the program plainly just once before entering actual data.
-> Add record(s) before using other options from the menu.*/
/*-----------------------------------------------------------------------------------------------------------------------------------*/

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
#define MAX 100
/*=================================================================================*/
/*======Structure for storing session details==========*/
struct session{
long int sc_code3;
char s_code[10];
int check;
char p_asn[10];
char p_viva[10];
char p_prac[10];
char p_theory[10];
};
/*=================================================================================*/
/*=======Structure for storing programme details=======*/
struct pdetails{
long int sc_code2;
char p_code[10];
char p_name[50];
char p_acon[50];
char p_inc[50];
int p_nos;
int nos_check;
};

/*=================================================================================*/
/*======Structure for storing study center details=====*/
struct scdetails{
long int sc_code;
char sc_name[50];
char sc_cood[50];
char sc_rc[50];
int sc_nop;
};
/*=================================================================================*/

struct scdetails s[MAX];


struct pdetails p[MAX];
struct session l[MAX];

char e[10]={'B','C','A'};
int m, x=0, y=0, r1=0, list, count=0;
/*=================================================================================*/
/*=========Function "addrecord()" to add records=========*/
/*---------------------------------------------1st Option from Main Menu--------------------------------------------------*/
void addrecord(){
int i, j, k=0, r, t;
printf("\n\n\tHow many records do you wish to enter(Integer): \n\t");
scanf("%d", &m);
m+=x;
for(i=(x+1); i<=m; i++){
printf("\n\n\tEnter the details for record - %d:", i);
test1:
printf("\n\n\tEnter the Code of the Study Center(Integer): \n\t");
scanf("%ld", &s[i].sc_code);

/*---------------------------------To check repeated entries of study center codes------------------------------------*/


if(i>1){
for(t=1; t<i; t++){
if(s[t].sc_code==s[i].sc_code){
printf("\n\n\tStudy Center already exists!");
printf("\n\tEnter a different Study Center Code");
goto test1;
}}}
/*-------------------------------------------------------------------------------------------------------------------------------------*/

printf("\n\n\tEnter the name of the Study Center: \n\t");


scanf("%s", &s[i].sc_name);
printf("\n\n\tEnter the name of the Study Center Coordinator: \n\t");
scanf("%s", &s[i].sc_cood);
printf("\n\n\tEnter the name of the Regional Center: \n\t");
scanf("%s", &s[i].sc_rc);
printf("\n\n\tEnter the no. of programs available(Integer): \n\t");
scanf("%d", &s[i].sc_nop);

/*----------------------------------------------------To enter program details------------------------------------------------*/


s[i].sc_nop+=y;
for(j=(y+1); j<=(s[i].sc_nop); j++){
p[j].sc_code2=s[i].sc_code;
k++;
test2:
printf("\n\n\tEnter the code for program(Uppercase)- %d:\n\t", k);
scanf("%s", &p[j].p_code);
/*----------------------To check repeated entries of program codes for same study center----------------------*/
if(j>1){
for(t=1; t<j; t++){
if(p[t].sc_code2==p[j].sc_code2){
if(!strcmpi(p[t].p_code, p[j].p_code)){
printf("\n\n\tProgram already exists for the given study center!");
printf("\n\tEnter a different Program Code");

goto test2;
}}}}
/*-------------------------------------------------------------------------------------------------------------------------------------*/
printf("\n\n\tEnter the name for program - %d:\n\t", k);
scanf("%s", &p[j].p_name);
printf("\n\n\tEnter the name of the Academic Councillor for Program %d:\n\t", k);
scanf("%s", &p[j].p_acon);
printf("\n\n\tEnter the name of the Incharge for Program %d:\n\t", k);
scanf("%s", &p[j].p_inc);

/*-------------------------------------------------------------------------------------------------------------------------------------*/
/*----------------------------------------------To enter session details-------------------------------------------------------*/
test3:
printf("\n\n\tNumber of sessions available for this program:(Integer)\n\t");
scanf("%d", &p[j].p_nos);
p[j].nos_check=p[j].p_nos;
p[j].p_nos+=r1;
list=k;
k=0;
if(p[j].p_nos>=1){
for(r=(r1+1); r<=(p[j].p_nos); r++){
k++;
l[r].sc_code3=p[j].sc_code2;
l[r].check=r;
printf("\n\n\tEnter the assignment schedule for session %d:\n\t", k);
scanf("%s", &l[r].p_asn);
printf("\n\n\tEnter the viva schedule for session %d:\n\t", k);
scanf("%s", &l[r].p_viva);
if(!strcmpi(e, p[j].p_code)){
printf("\n\n\tEnter the Practical schedule for BCA session %d:\n\t", k);
scanf("%s", &l[r].p_prac);

printf("\n\n\tEnter the Theory schedule for BCA session %d:\n\t", k);


scanf("%s", &l[r].p_theory);
}
strcpy(l[r].s_code, p[j].p_code);
r1=(p[j].p_nos);
count++;
}
k=list;
}
else{
printf("\n\n\tEnter at least one session!");
goto test3;
}
y=(s[i].sc_nop);
}
k=0;
}
x=m;
clrscr();
}
/*-------------------------------------------------------------------------------------------------------------------------------------*/
/*============Function "addrecord()" ends=================*/
/*=================================================================================*/

/*=================================================================================*/
/*=======Function"disprecord()" to display records===========*/

void disprecord(int op){


int i, j, b1, c, u=0, v=0;
long int o;

char a1[10];
printf("\n\n\tEnter a Study Center Code to view the details\n\t");
scanf("%ld", &o);
for(i=1; i<=x; i++){
if(o==s[i].sc_code){
printf("\n\n\tQuery Results:\n\t");
printf("\n\t--------------------------------------");
printf("\n\tStudy Center Code: %d", o);
printf("\n\tName of the Study Center: %s", s[i].sc_name);
printf("\n\tName of the Regional Center: %s", s[i].sc_rc);
printf("\n\t--------------------------------------");
printf("\n\tPrograms:");
u=1;
/*--------------------------------------------2nd Option from Main Menu--------------------------------------------------*/
if(op==2){
for(j=1; j<=y; j++){
if(o==p[j].sc_code2){
printf("\n\t");
printf("\n\t-------------------------------------------------------\n\t");
printf("-> %s", p[j].p_code);
printf("\n\n\tProgramme name: %s\n\t", p[j].p_name);
printf("\n\tSessions available: ");
for(c=1; c<=p[j].nos_check; c++){
printf("%d ",c);
}
printf("\n\tAcademic Councillor: %s\n\t", p[j].p_acon);
printf("\n\tProgramme In-charge: %s\n\t", p[j].p_inc);
printf("\n\t-------------------------------------------------------\n\t");
v=1;
}}}

/*-------------------------------------------------3rd Option from Main Menu----------------------------------------------*/


else if(op==3){
printf("\n\n\tEnter a session number for BCA: \n\t");

scanf("%d", &b1);
for(c=1; c<=count; c++){
if(o==l[c].sc_code3){
if(!strcmpi(e,l[c].s_code)){
if(b1==1){
printf("\n\t-------------------------------------------------------");
printf("\n\tTheory schedule for BCA Programme: %s\n\t", l[c].p_theory);
printf("\n\tPractical schedule for BCA Programme: %s\n\t", l[c].p_prac);
printf("\n\t-------------------------------------------------------");
v=1;
break;
}
else{
b1--;
printf("\n\t-------------------------------------------------------");
printf("\n\tTheory schedule for BCA Programme: %s\n\t", l[c+b1].p_theory);
printf("\n\tPractical schedule for BCA Programme: %s\n\t", l[c+b1].p_prac);
printf("\n\t-------------------------------------------------------");
v=1;
break;
}}}}}

/*-------------------------------------------------4th Option from Main Menu---------------------------------------------*/


else if(op==4){
printf("\n\n\tEnter a program code: \n\t");
scanf("%s", &a1);
for(j=1; j<=y; j++){
if(o==p[j].sc_code2){
if(!strcmpi(a1,p[j].p_code)){
printf("\n\t-------------------------------------------------------");
printf("\n\n\tAcademic Councillor for the given Programme: %s", p[j].p_acon);
printf("\n\t-------------------------------------------------------");
v=1;
}}}}

/*----------------------------------------------5th Option from Main Menu------------------------------------------------*/


else {
printf("\n\n\tEnter a program code: \n\t");
scanf("%s", &a1);
printf("\n\n\tEnter a session number for the program: \n\t");
scanf("%d", &b1);
for(c=1; c<=count; c++){
if(o==l[c].sc_code3){
if(!strcmpi(a1,l[c].s_code)){
if(b1==1){
printf("\n\t----------------------------------------");
printf("\n\tAssignment Submission Schedule: %s\n\t", l[c].p_asn);
printf("\n\tViva-Voice Schedule: %s\n\t", l[c].p_viva);
printf("\n\t----------------------------------------");
v=1;
break;
}
else{
b1--;
printf("\n\t----------------------------------------");
printf("\n\tAssignment Submission Schedule: %s\n\t", l[c+b1].p_asn);
printf("\n\tViva-Voice Schedule: %s\n\t", l[c+b1].p_viva);
printf("\n\t----------------------------------------");
v=1;
break;
}}}}}}}

if(u==0||v==0)
printf("\n\n\tNot Found!");
}
/*==============Function "disprecord()" ends=================*/
/*=================================================================================*/

/*=================================================================================*/
/*============MAIN PROGRAM==============*/
void main(){
int ch;
char chh;
void addrecord(void);
line:
printf("\n\n************************************************************************\n");
printf("\n\t 1- Add Study Center Records");
printf("\n\t 2- View the details of programs available in a Study Center");
printf("\n\t 3- View the Theory/Practical schedule for BCA programme");
printf("\n\t 4- View the Academic Councilor concerned with a programme");
printf("\n\t 5- View the Assignment/Viva voce schedules of a programme");
printf("\n\n\t 6- Exit");
printf("\n\n************************************************************************\n");
printf("\n -> NOTE: 1.Please use underscores(_) instead of spaces while entering data");
printf("\n
2.Enter schedules or dates in DD/MM/YY format");
printf("\n\n************************************************************************\n");
printf("\n\tEnter Your Choice:");
printf("\n\n\t");
scanf("%d",&ch);
switch(ch){
case 1:
addrecord();
break;
case 2:
disprecord(ch);
break;
case 3:
disprecord(ch);
break;
case 4:
disprecord(ch);

break;
case 5:
disprecord(ch);
break;
case 6:
clrscr();
exit(0);
break;

default:
printf("\n\n\tInvalid choice!");
break;
}
line2:
printf("\n\n--------------------------------------------------------------------------------");
printf("\n\n\tDo you want to continue(y/n): \n\n\t");
scanf("%s", &chh);
if(chh=='y'){
clrscr();
goto line;
}
else if(chh=='n'){
clrscr();
exit(0);
}
else {
clrscr();
printf("\n\n\tInvalid entry!!!");
goto line2;
}
getch();
}

/*===============END================*/
/*=================================================================================*/