Sunday, November 27, 2011

C Program for Short Instant Quiz


#include<stdio.h>
#include<conio.h>
#include<string.h>
void prn();
int questions(char []);
int m1=0;
int m=0;
void main()
{
int i;
long ht;
char name[20];
char f1[10];
char ch[50]=" STATE TRUE OR FALSE . EACH CARRIES ONE MARK ";
clrscr();
prn();
 gotoxy(5,4);
 printf(" Student Name : ");
 scanf("%s",&name);
 gotoxy(5,6);
 printf(" HALL TICKET NUMBER : ");
 scanf("%ld",&ht);
clrscr();
prn();
gotoxy(2,5);
printf("%s",ch);
gotoxy(2,6);
for(i=0;i<strlen(ch);i++)
printf("-");
printf("\n\n");
questions(f1);
clrscr();
prn();
printf("\n\n");
printf(" STUDENT NAME  : %s",name);
printf("\n HALL-TICKET NUMBER  : %ld",ht);
printf("\n TOTAL MARKS  : %d",m);
getch();
}


void prn()
{
gotoxy(25,2);
printf(" C EXAMINATION ");
gotoxy(25,3);
printf(" ----------- ");
}




int questions(char f[])
{
printf(" 1. Structure is not a data type : ");
scanf("%s",&f[0]);
if(f[0]==102 || f[0]==70)
m++;
printf("\n");


printf(" 2. C Program is a collection of functions : ");
scanf("%s",&f[1]);
if(f[1]==116 || f[1]==80)
m++;
printf("\n");


printf(" 3. In an array we can accept more than one value of same type : ");
scanf("%s",&f[2]);
if(f[2]==116 || f[2]==84)
m++;
printf("\n");


printf(" 4. String is a character array : ");
scanf("%s",&f[3]);
if(f[3]==116 || f[3]==84)
m++;
printf("\n");


printf(" 5. Any function cannot be called from any other function  : ");
scanf("%s",&f[4]);
if(f[4]==102 || f[4]==70)
m++;
printf("\n");


printf(" 6. fflush() is a macro  : ");
scanf("%s",&f[5]);
if(f[5]==102 || f[5]==70)
m++;
printf("\n");


printf(" 7. When the file is opened in 'a+' mode modification is possible  : ");
scanf("%s",&f[6]);
if(f[6]==102 || f[6]==84)
m++;
printf("\n");


printf(" 8. Break is a reverse word  : ");
scanf("%s",&f[7]);
if(f[7]==116 || f[7]==84)
m++;
printf("\n");


printf(" 9. STRCHR finds the first occurence of a given character in a string  : ");
scanf("%s",&f[8]);
if(f[8]==116 || f[8]==84)
m++;
printf("\n");


printf(" 10. exit() fn is present in iomanip.h  : ");
scanf("%s",&f[9]);
if(f[0]==102 || f[0]==70)
m++;


return m;
}

No comments:

Post a Comment