CPF ReportDocument From
CPF ReportDocument From
CE – 101
Fall Semester 2020-21
FINAL PROJECT
Submitted by:
Faizan khan (ROLL NO: 143)
Arisha Fateh (ROLL NO: 117)
Syed Aoun Raza Naqvi (ROLL NO:
104)
Section: - C
Submitted to : - Sir Ali Akbar
1
Department of Computer Engineering
Sir Syed University of Engineering and Technology
TABLE OF CONTENT:
S.NO CONTENTS
1 ACKNOWLEDGE
2 INTRODUCTION TO C LANGUAGE
3 PROJECT OVERVIEW
4 PROGRAM
5 CONCLUSION
ACKNOWLEDGE:
We would like to thank our beloved “SIR ALI AKBAR”, the faculty of
our course Computing & Programming Fundamental (CE-101L and
CE-101T)
Yours faithfully,
2
Department of Computer Engineering
Sir Syed University of Engineering and Technology
INTRODUCTION
3
Department of Computer Engineering
Sir Syed University of Engineering and Technology
INTRODUCTION TO C LANGUAGE:
Operating Systems like Windows, and many other complex programs like
4
Department of Computer Engineering
Sir Syed University of Engineering and Technology
PROJECT OVERVIEW:
INTRODUCTION TO THE PROJECT:
This project is totally based on “Quiz Game ”.
This project is all about quiz game . When user will open this project
some options will get displayed on the screen such as , start the quiz
and end the quiz now it’s totally upto the user to choose whatever
option he wants to . If he wants to play the game then user will
definitely choose (start the quiz) and by picking up that option he will
be asked to write his first and last name and project will show the
player name. After this little process player will get three questions
each question containing 5 marks after going through this questions
answers period , he will be rewarded his marks out of 15 and will get
his remarks based on the marks that he has got in the quiz . In the end
it will ask the user to press any button the close the quiz . If the user
chooses the second option which is (end the quiz) in the very beginning
then quiz will be closed without displaying any of the above mentioned
process
5
Department of Computer Engineering
Sir Syed University of Engineering and Technology
6
Department of Computer Engineering
Sir Syed University of Engineering and Technology
7
Department of Computer Engineering
Sir Syed University of Engineering and Technology
Command Used in program are switch break statement and nested if
else loop.
The break statement is used inside the switch to terminate a statement sequence.
When a break statement is reached, the switch terminates, and the flow of control jumps
to the next line following the switch statement.
The break statement is optional. If omitted, execution will continue on into the next case.
The if statement alone tells us that if a condition is true it will execute a block of statements
and
if the condition is false it won’t. But what if we want to do something else if the condition is
false.
Here comes the C else statement. We can use the else statement with
if statement to execute a block of code when the condition is false.
8
Department of Computer Engineering
Sir Syed University of Engineering and Technology
9
Department of Computer Engineering
Sir Syed University of Engineering and Technology
Object: -
A Program for Game quiz using C Language.
Source Code: -
#include<stdio.h>
#include<conio.h>
#include<cstdlib>
int main()
{
int i,a,score,y;
char first_name[100],Remarks;
char last_name[60];char ch;
system("color 74");
printf("\n\n\t\t\t
=========================================================");
printf("\n\n\t\t\t * PREPARED BY ARISHA FATEH, AOUN RAZA AND
FAIZAN KHAN *");
printf("\n\n\t\t\t
=========================================================");
printf("\n\n\t\t\t\t\t *WELCOME TO QUIZ GAME**");
printf("\n\n\t 1. START THE QUIZ : \n\t 2. QUIT THE QUIZ : \t\t\n ");
printf("\n\t ENTER A NUMBER : ");
scanf(" %d",&i);
switch (i)
10
Department of Computer Engineering
Sir Syed University of Engineering and Technology
{
case 1:
printf(" \n\n\n Enter Your First Name: ");
scanf(" %s",&first_name);
printf("\n Enter Your Last Name : ");
scanf("%s",&last_name);
printf("\n Player Name Is: %s %s",first_name,last_name);
printf("\n\n\n\t\t\t\t Press enter key to continue");
getch();
system("cls");
system("color 75");
printf("\n\n\t\t\t [ SELECT AND ENTER THE ANSWER NO... ]");
printf("\n\n\n\n\t\t\t Q1.What Is The Capital Of The Pakistan ?");
//Question 1
printf(" \n\n\n\t\t\t 1.Islamabad \n\t\t\t 2.Karachi\n\t\t\t 3.Peshawar\n");
printf("\n\t\t\tEnter your Choice: ");
scanf("\t\t\t%d",&a);
if (a==1)
printf(" \n\t\t\t CORRECT !!!");
if (a==1)
11
Department of Computer Engineering
Sir Syed University of Engineering and Technology
score=score+5;
else if (a==2,3)
printf("\n\t\t\t WRONG !!!");
printf("\n\n\t\t\t Press enter key to continue");
getch();
system("cls");
system("color 70");
printf("\n\n\t\t\t [ SELECT AND ENTER THE ANSWER NO... ]");
printf("\n\n\n\n\n\t\t\t Q2.Who is the best T20 player of Pakistan ?\n");
//Question 2
printf(" \n\n\n\t\t\t 1.Fakhar \n\t\t\t 2.Haider\n\t\t\t 3.Babar");
printf("\n\n\t\t\tEnter your Choice: ");
scanf(" %d",&a);
if (a==3)
printf(" \n\n\t\t\t CORRECT !!!");
if(a==3)
score = score+5;
else if (a==1,2)
printf("\n\t\t\t WRONG !!!");
else
printf("\n\t\t\t INVALID !!! ");
printf("\n\n\t\t\t Press enter key to continue");
12
Department of Computer Engineering
Sir Syed University of Engineering and Technology
getch();
system("cls");
system("color 71");
printf("\n\n\t\t\t [ SELECT AND ENTER THE ANSWER NO... ]");
printf("\n\n\n\n\n\t\t\t Q3.Who was the captian of Pakistan when Pakistan won
the cricket world cup ?\n"); //Question 3
printf(" \n\n\n\t\t\t 1.Javed miandad \n\t\t\t 2.Imran khan\n\t\t\t 3.Waseem
Akram");
printf("\n\n\t\t\tEnter your Choice: ");
scanf(" %d",&a);
if (a==2)
printf(" \n\n\t\t\t CORRECT !!!");
if (a==2)
score = score+5;
else if (a==1,3)
printf("\n\t\t\t WRONG !!!");
else
printf("\n\n\t\t\t Press enter key to continue");
getch();
system("cls");
system("color 7C");
printf("\n\n\n\n\t\t\t Final Result: ");
13
Department of Computer Engineering
Sir Syed University of Engineering and Technology
printf("\n\n\n\n\n\t\t\t Total Score = 15 \n");
printf("\n\t\t\t Obtain Score = %d\n\n\t\t\t",score);
if(score==15)
printf(" Remarks: Excellent ");
else if(score==10)
printf(" Remarks: Good ");
else if(score==5)
printf(" Remarks: Fair ");
else if(score==0)
printf(" Fail ");
printf(" %c ",Remarks);
printf("\n\n\n\n\t\t\t Press enter key to continue");
getch();
system("cls");
case 2:{
printf("\n\n\n\n\t\t\t\t Now you can quit the quiz !!!!!\n\n \t\t\t\tpress any key to quit\n\t\t\t");
scanf("%c",&ch);
if(ch=='y')
printf("\t\t\tyou have quit the game quiz");
break;
}
default :
14
Department of Computer Engineering
Sir Syed University of Engineering and Technology
printf("\n\n\t\t\t invalid input !!!!");
break;
}
return 0;
}
15
Department of Computer Engineering
Sir Syed University of Engineering and Technology
OUTPUT
16
Department of Computer Engineering
Sir Syed University of Engineering and Technology
17
Department of Computer Engineering
Sir Syed University of Engineering and Technology
18
Department of Computer Engineering
Sir Syed University of Engineering and Technology
CONCLUSION:
In this program , we use the command of Switch and break statement
nested if else and for loop statement.
,using both of them we calculated the total bill of the consumer in c language.
This program helps us to calculate the bill in minimum time.
In quiz game, questions are chosen in such a a way that they cover all
fields of a typical quiz contest. The user’s general knowledge is tested with
quiz questions .
The source code is to be compiled on Dev c++. The source code for
this mini project is around 114 lines & also submitted through usb.
THANKS
19
Department of Computer Engineering
Sir Syed University of Engineering and Technology
20
Department of Computer Engineering
Sir Syed University of Engineering and Technology