By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,214 Members | 2,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,214 IT Pros & Developers. It's quick & easy.

have 3 errors could not able to find it can some help finding them

P: 1
this my pgm
can anyone help me finding my errors
#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
struct ques
{ char a[100];
char ans;
} q[20];
void menu();
void startquiz(ques q[20]);
void add(ques q[20]);
void rem(ques q[20]);
void leveltwo(ques q[20],int score);

void main()
{
clrscr();
int ch,z,n;
q[1].a[100]={"1.the capital of honduras is: A.Tegucigalpa B.Port Louis C.Kingston";}
q[2].a[100]={"2.who won the nobel prize for physics in 2013? A.Jane Goodall B.Peter Higgs and Francois Elgort C.Alan Aspect";}
q[3].a[100]={"3.who is the vice president of USA? a.Joe biden b.Hilary clinton c.Mike pence";}
q[4].a[100]={"4.Triskaedophobia is the fear of________ A.Mirrors B.Beards C.Number 13";}
q[5].a[100]={"5.which of these was the first e-commerce company?A.Alibaba B.Amazon C.Snapdeal ";}
q[6].a[100]={"6.who is the father of internet? A.Vinton Cerf B.Charles Babbage C.Marconi ";}
q[7].a[100]={"7.who is the CEO of twitter? A.Merissa Mayer B.Jack Dorsey C.Steve Jobs";}
q[8].a[100]={"8.who is the founder of amul? A.Mohammad Younas B.Vinoba Bhave C.Varghese Kurian";}
q[9].a[100]={"9.what was the word of the year 2013? A.Selfie B.Thug C.Swag ";}
q[10].a[100]={"10.the olive leaf represents what symbol? A.Humanity B.Victory C.Peace";}
q[11].a[100]={"11.which game is associated with yonex cup? A.Golf B.Baseball C.Batminton";}
q[12].a[100]={"12. Who invented the electric razor? A.K.G Gillete B. Col.J.Schick C. L.C Young";}
q[13].a[100]={"13. When was Abraham Lincoln re-elected as the president of US? A.1864 B. 1814 C.1819";}
q[14].a[100]={"14. Which mirror is used as rear view mirror in vehicles? A.Plain B.Concave C.Convex";}
q[15].a[100]={"15. Former prime minister Charan singh was related to which political party? A.Lok Dal B. AIADMK C.Janata Dal ";}
q[16].a[100]={"16. How many centuries did Sachin score against Kenya? A.2 B.4 C.3";}
q[17].a[100]={"17.Who is known as the 'Father of Geometry'?A.Kepler B.Euclid C.Pythagoras";}
q[18].a[100]={"18.What is October 8th celebrated for? A.Army Day B.U.N.O Day C.Airforce Day";}
q[19].a[100]={"19.18 carat gold contains? A.18% gold B.60% gold C.75%gold";}
q[20].a[100]={"20.What is the National Emblem of Denmark A.Beach B.Rose C.Lily";}
cout<<"******************************************* ***";
cout<<" ******************************************** ";
cout<<" **************************************** ";
cout<<" ************************************ ";
cout<<" ******************************** ";
cout<<" **************************** ";
cout<<" ************************ ";
cout<<" ******************** ";
cout<<" **************** ";

cout<<" QUIZ ";

cout<<" **************** ";
cout<<" ******************** ";
cout<<" ************************ ";
cout<<" **************************** ";
cout<<" ******************************** ";
cout<<" ************************************ ";
cout<<" **************************************** ";
cout<<" ******************************************** ";
cout<<"******************************************* ***";
cout<<"\nENTER YOUR CHOICE(1-3)";
cin>>ch;
do
{
switch(ch)
{
case 1: cout<<"\n1.Add more questions\n2.Remove questions\n3.Return to main menu";
cin>>n;
if(n==1)
add(q);
else if(n==2)
rem(q);
else
menu();
break;
case 2: cout<<"\n1.Start Quiz\n2.Return to main menu";
cin>>z;
if(z==1)
startquiz(q);
else
menu();
break;
case 3: exit(0);
break;
default:cout<<"\nWRONG CHOICE";
break;
}
}while(ch!=0);
getch();

}
void startquiz(ques q[20])
{
char ans[5];
int score =0;
cout<<"\n"<<"please read the following instructions to continue the quiz";
clrscr();
cout<<"******************************************* *********";
cout<<"\n"<<"WELCOME TO THE QUIZ GAME";
cout<<"\n you will be asked a question and three options will be given with it";
cout<<"\n each correct answer gets 10 points and a wrong answer means no points";
cout<<"\n ************************************************** **";
cout<<"\n YOU WILL NOW START THE QUIZ";
clrscr();
for(int i=1;i<11;i++)
{
cout<<"\n"<<"QUESTION"<<i;
cout<<"\n"<<q[i].a[100];
cout<<"\n"<<"enter answer(a,b or c)";
cin>>q[i].ans;
clrscr();
}
if(q[1].ans=='a')
score+=10;
if(q[2].ans=='b')
score+=10;
if(q[3].ans=='a')
score+=10;
if(q[4].ans=='c')
score+=10;
if(q[5].ans=='a')
score+=10;
if(q[6].ans=='a')
score+=10;
if(q[7].ans=='b')
score+=10;
if(q[8].ans=='c')
score+=10;
if(q[9].ans=='a')
score+=10;
if(q[10].ans=='c')
score+=10;
clrscr();
if(score>=60)
leveltwo(q,score);
else
{
cout<<"YOUR SCORE IS"<<score;
cout<<"\n"<<"unfortunately.you have not passed to level 2 of the game";
cout<<"\n"<<"************************************* *******************";
cout<<"\n"<<"GAME OVER!!!";
exit(0);
}

void leveltwo(ques q[20],int score);
{
clrscr();
char ans;
cout<<"\nNOW YOU ARE IN LEVEL TWO";
cout<<"\nLets Continue";
for(int i=11;i<21;i++)
{
cout<<"\n"<<"QUESTION"<<i;
cout<<"\n"<<q[i].a[100];
cout<<"\n"<<"enter answer a,b or c";
cin>>q[i].ans;
clrscr();
}
if(q[11].ans=='c')
score+=10;
if(q[12].ans=='b')
score+=10;
if(q[13].ans=='a')
score+=10;
if(q[14].ans=='c')
score+=10;
if(q[15].ans=='a')
score+=10;
if(q[16].ans=='b')
score+=10;
if(q[17].ans=='b')
score+=10;
if(q[18].ans=='c')
score+=10;
if(q[19].ans=='c')
score+=10;
if(q[20].ans=='a')
score+=10;
cout<<"******************************************* ***********";
cout<<"CONGRATULATIONS....YOUR SCORE IS"<<score;
}
void rem(ques q[100])
{
int c=0,p,loc,k,i;
cout<<"Enter the question number of the question you wish to delete"<<"\n";
cin>>(ques.a);
cout<<"enter the location you want to delete the question from";
cin>>loc;
for(i=0;st[ques.a]!='\0';i++)
c++;
k=c;
p=c-1;
for(i=loc;i<p;i++)
q[i]=q[i+1];
k--;
cout<<"final display";
for(i=0;i<k;i++)
cout<<q[i]<<"\t";
}
void add (ques q[100])
{
char inst;
int n;
cout<<"enter the question number";
cin>>n;
cout<<"enter question to be inserted" ;
gets(ques.a);
cout<<"\n"<<"enter answer";
cin>>(inst.ans);
for(int i=n;i<n+1;i--)
q[i]=q[i-1];
q[n]=inst;
}
void menu()
{
cout<<"\nMENU";
cout<<"\n1.Admin Menu";
cout<<"\n2.User Menu";
cout<<"\n3.Exit";
}
Jan 16 '17 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 2,398
It would be a lot easier to help you if you enclosed your source code in CODE tags. Then there would be line numbers so we could refer to specific lines.

You are using C++. My understanding is that standard headers in C++ don't end in .h.

An array of size N is referenced by indices 0 to N-1. You are using indices 1 to N.

Don't know about C++, but C doesn't let you simply assign a quote-enclosed string to a char array.
Jan 17 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.