main()
{
char c;
printf("This is your Programming Language Knowledge Test of C, developed in C by the \"Amit Ranjan\".\n");
printf("There are 20 multiple Choice Question of 5 marks each.\n");
printf("Total marks :- 100\nTime:- 90 min\nEvery Question is compulsary.");
printf("First read questions carefully and then answer it.");
z:printf("\nDo You Want To Proceed (y/n) :- ");
c=getche();
switch(c)
{
case 'Y':
case 'y':detail();
break;
case 'N':
case 'n': printf("\nGood Luck, and Be Prepared for the next time\n");
break;
default: printf("\nInvalid Choice");
goto z;
}
getch();
}
detail()
{
char name[20],password[20],pw[20];
int i;
printf("\nEnter your name :- ");
gets(name);
printf("Enter password :- ");
i=0;
while(1)
{
pw[i]=getch();
if(pw[i]==' ' || pw[i] == '\r')
{
pw[i]='\0';
password[i]='\0';
break;
}
else
{
password[i]=pw[i];
printf("*");
}
i++;
}
printf("\n");
if(strcmp(password,"najnartima")==0)
{
printf("Welcome! Miss./Mrs./Mr.");
puts(name);
printf("Now best of luck for your test.");
printf("\nPress any key............");
getch();
test();
}
else
{
printf("Sorry! Invalid password.You are not elegible for this test.");
}
}
test()
{
int c,w;
char ans;
c=0;w=0;
clrscr();
printf("\n1. What do you mean by Conditional Compilation ?\n");
printf("a. It is taken care of by the compiler\nb. It is setting the compiler options conditionally\nc. It is compiling a program based on condition\nd. None of Above\n");
printf("\nAns : - ");
ans=getche();
if(ans=='C' || ans=='c')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n2. Originally C was developed as ? \n");
printf("a. System Programming Language\nb. General Purpose Language \nc. Data Processing Language \nd. None of above\n");
printf("\nAns : - ");
ans=getche();
if(ans=='A' || ans=='a')
{c++; printf("\nCorrect");}
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("3. Minimum number of temporary variable needed to swap the contents of 2 variable is ? \n");
printf("a. 1\nb. 2\nc. 3\nd. 0");
printf("\nAns : - ");
ans=getche();
if(ans=='D' || ans=='d')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); } printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n4. *ptr++ is equivalent to ?\n");
printf("a. ptr++\nb. *ptr\nc. ++*ptr\nd. None of Above");
printf("\nAns : - ");
ans=getche();
if(ans=='D' || ans=='d')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n5. Expression C=i++ Causes ?\n");
printf("a. Value of i is assigned to C and then I is incremented by 1\nb. i to be incremented by 1, and then value of i assigned to C\nc. Value of i assigned to C\nd. i to be incremented by 1");
printf("\nAns : - ");
ans=getche();
if(ans=='a' || ans=='A')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n6. Declaration int *(*p) int(*a)(i) is ?\n");
printf("a. A pointer to function that accepts an integer argument and returns an integer\nb. A pointer to a, which returns an integer\nc. A pointer to subroutine, which returns result of evaluation\nd. None of Above");
printf("\nAns : - ");
ans=getche();
if(ans=='A' || ans=='a')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n7. Null pointer and UN-initialized pointers are same ?\n");
printf("a. True\nb. False\nc. Varies from program to program\nd. None of Above");
printf("\nAns : - ");
ans=getche();
if(ans=='B' || ans=='b')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n8. In which header file Null macro is defined ? \n");
printf("a. stdio.h and stddet.h\nb. iostream.h\nc. string.h\nd. Preprocessor");
printf("\nAns : - ");
ans=getche();
if(ans=='A' || ans=='a')
{ c++; printf("\nCorrect");}
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n9. Null pointer is ?\n");
printf("a. A pointer which does not point anywhere\nb. Pointer defined with name Null\nc. A pointer that returns 0 values\nd. None of Above");
printf("\nAns : - ");
ans=getche();
if(ans=='A' || ans=='a')
{ c++; printf("\nCorrect");}
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n10. Null macro is ?\n");
printf("a. A macro with name Null\nb. A macro which represents Null pointer\nc. A macro defined with no name\nd. None of Above");
printf("\nAns : - ");
ans=getche();
if(ans=='B' || ans=='b')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n11. Which of the following is not true in context of C language ?\n");
printf("a. It is array of characters\nb. Last character of character array is always \\0\nc. C inserts the null character automatically\nd. Any string in C can be read by the function getchar()");
printf("\nAns : - ");
ans=getche();
if(ans=='B' || ans=='b')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n12. Which of the following operations can not be perform on pointers in C ?\n");
printf("a. Addition of two pointers\nb. Subtraction of a number from a pointer\nc. Subtraction of one pointer from another\nd. Addition of a number to a pointer");
printf("\nAns : - ");
ans=getche();
if(ans=='C' || ans=='c')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n13. Which is not a programming language?\n");
printf("a. C\nb. C#\nc. F#\nd. Z#");
printf("\nAns : - ");
ans=getche();
if(ans=='D' || ans=='d')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n14. What is the output of C statement 7.5 % 3 ?\n");
printf("a. 1.5 \nb. 1\nc. No output\nd. 2");
printf("\nAns : - ");
ans=getche();
if(ans=='B' || ans=='b')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n15. Any program in C has access to three standard files?\n");
printf("a. standard input file, standard output file, standard error file\nb. stdin, stdout, stderr\nc. keywords, screen, stderr\nd. All of above\ne. None of Above");
printf("\nAns : - ");
ans=getche();
if(ans=='C' || ans=='c')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n16. An identifier in C ?\n");
printf("a. is a name of thing such as variable and function\nb. is made up of letters, numerals and the underscore\nc. can contain both uppercase and lowercase letters\nd. All of above\ne. None of Above");
printf("\nAns : - ");
ans=getche();
if(ans=='C' || ans=='c')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n17. The single character input/output functions are ?\n");
printf("a. scanf( ) and printf( )\nb. getchar( ) and printf( )\nc. scanf( ) and putchar( )\nd. getchar( ) and putchar()\ne. None of Above");
printf("\nAns : - ");
ans=getche();
if(ans=='C' || ans=='c')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n18. Precedence determines which operator ?\n");
printf("a. is evaluated first\nb. is most important\nc. is fastest\nd. Operates on the largest number\ne. None of Above");
printf("\nAns : - ");
ans=getche();
if(ans=='B' || ans=='b')
{ c++; printf("\nCorrect");}
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n19. Who develope the C programming language?\n");
printf("a. Charls Babbage\nb. Dennis Richard\nc. Dennis Ritchie\nd. James Gosling\ne. None of them");
printf("\nAns : - ");
ans=getche();
if(ans=='C' || ans=='c')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for next question........");
getch();
clrscr();
printf("\n20. The two operators && and || are ?\n");
printf("a. Arithmetic operator\nb. Equality operators\nc. Logical operators\nd. Relational operators\ne. None of Above");
printf("\nAns : - ");
ans=getche();
if(ans=='D' || ans=='d')
{ c++; printf("\nCorrect"); }
else
{ w++; printf("\nIncorrect"); }
printf("\nPress any key for your result........");
getch();
clrscr();
result(c,w);
}
result(int c,int w)
{
printf("You had given %d right answers and %d wrong answers\n",c,w);
printf("Your total marks is %d\n",c*5);
if(c*5>=90)
printf("Your Grade is : \'A+\'");
else if(c*5<90 && c*5>=80)
printf("Your Grade is : \'A\'");
else if(c*5<80 && c*5>=70)
printf("Your Grade is : \'B+\'");
else if(c*5<70 && c*5>=65)
printf("Your Grade is : \'B\'");
else if(c*5<65 && c*5>=60)
printf("Your Grade is : \'C\'");
else
printf("Sorry, You Fail!!!!!Better luck next time");
}
Output:-
No comments:
Post a Comment