Scholarship Test For 3 Month Online Project Development Program (Sep'10-nov'10)

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Collegeprojectin
C
Collegeprojectin
Community Contributor
Quizzes Created: 1 | Total Attempts: 2,982
| Attempts: 2,982 | Questions: 16
Please wait...
Question 1 / 16
0 %
0/100
Score 0/100
1. Main(){int i=3;switch(i){default:printf("zero");case 1: printf("one");break;case 2:printf("two");break;case 3: printf("three");break;}} 

Explanation

* is a dereference operator & is a reference operator. They can be applied any number of times provided it is meaningful. Here p points to the first character in the string "Hello". *p dereferences it and so its value is H. Again & references it to an address and * dereferences it to the value H.

Submit
Please wait...
About This Quiz
Scholarship Test For 3 Month Online Project Development Program (Sep10-nov10) - Quiz


www. Collegeproject. In has launched scholarships (Rs. 4000) for meritorious students for our 3-Month Online Project development Program (Sep2010-Nov-2010).

Pass mark is 60%. The students who have... see morepassed in the test will be mailed the coupon code within 24 hours.
The students will have to enter the same coupon code at the time of payment and he will get a scholarship discount of Rs4000/ only.
Student must enter the same email id which has been used registration with www. Collegeproject. In.
Student must enter their mobile no as their unique id no.
For any query write to us at project@collegeproject. In or call 9311481855.
All the best. see less

2. # include aaa() { printf("hi"); } bbb(){ printf("hello"); } ccc(){ printf("bye"); } main() { int (*ptr[3])(); ptr[0]=aaa; ptr[1]=bbb; ptr[2]=ccc; ptr[2]();

Explanation

The given code snippet defines three functions: aaa, bbb, and ccc. These functions each print a different greeting message. In the main function, an array of function pointers called ptr is declared. The elements of this array are then assigned the addresses of the aaa, bbb, and ccc functions. Finally, the function pointed to by ptr[2] is called, which is ccc. Therefore, the output of the program would be "bye".

Submit
3.
main(){int *j;{int i=10;j=&i;}printf("%d",*j);} 

Explanation

Due to the assignment p[1] = 'c' the string becomes, "%c\n". Since this string becomes the format string for printf and ASCII value of 65 is 'A', the same gets printed.

Submit
4. Void main()
{
int i;
char a[]="\0";
if(printf("%s\n",a))
printf("Ok here \n");
else
printf("Forget it\n");

}

Explanation

Printf will return how many characters does it print. Hence printing a null character returns 1 which makes the if statement true, thus "Ok here" is printed.

Submit
5. Main(){char s[ ]="man";int i;for(i=0;s[ i ];i++)printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);}What will be the second output of printf?

Explanation

s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array
name is the base address for that array. Here s is the base address. i is the index number/displacement from
the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is
same as s[i].

Submit
6. Main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}

Explanation

Explanation:
For floating point numbers (float, double, long double) the values cannot be predicted
exactly. Depending on the number of bytes, the precession with of the value represented varies. Float
takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
Rule of Thumb:
Never compare or at-least be cautious when using floating point numbers with relational
operators (== , >, =,!= ) .

Submit
7. Main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}

Explanation

\n - newline
\b - backspace
\r - linefeed

Submit
8.
#includemain(){int i=1,j=2;switch(i){case 1: printf("GOOD");break;case j: printf("BAD");break;}}

Explanation

Explanation:
The case statement can have only constant expressions (this implies that we cannot use
variable names directly so an error).
Note:
Enumerated types can be used in case statements.

Submit
9. Main(){int i=0;for(;i++;printf("%d",i)) ;printf("%d",i);}

Explanation

The code snippet is a C program that starts with initializing an integer variable i to 0. It then enters a for loop with an empty initialization statement, a condition of i++, and an empty increment statement. This means that i will be incremented after each iteration of the loop. Inside the loop, the printf function is used to print the value of i. However, since the condition i++ is always evaluated as true, the loop becomes an infinite loop. Therefore, the program will continuously print the incremented value of i, starting from 1. Hence, the correct answer is 1.

Submit
10. #include #define a 10main(){#define a 50printf("%d",a);} 

Explanation

Runtime error-Stack overflow.main function calls itself again and again. Each time the function is called its return address is stored in the call stack. Since there is no condition to terminate the function call, the call stack overflows at runtime. So it terminates the program and results in an error.

Submit
11. #define FALSE -1#define TRUE 1#define NULL 0main() {if(NULL)puts("NULL");else if(FALSE)puts("TRUE");elseputs("FALSE");} 

Explanation

The code snippet defines FALSE as -1, TRUE as 1, and NULL as 0. In the main function, the if statement checks if NULL is true. Since NULL is defined as 0, which is considered false, the if statement evaluates to false. The else if statement then checks if FALSE is true. Since FALSE is defined as -1, which is considered true, the else if statement evaluates to true. Therefore, the code will print "TRUE" as the output.

Submit
12. Main(){int a[10];printf("%d",*a+1-*a+3);

Explanation

The given code declares an integer array 'a' of size 10. In the printf statement, the expression *a+1-*a+3 is evaluated. Since 'a' is an array, *a refers to the value at the first index of the array, which is the same as a[0]. So, *a+1 is equivalent to a[0]+1. Similarly, *a+3 is equivalent to a[0]+3. Therefore, the expression simplifies to a[0]+1-a[0]+3, which further simplifies to 1+3, resulting in the value 4 being printed.

Submit
13. Register int a=2;
printf("Address of a = %d",&a);
printf("Value of a = %d",a);
}

Explanation

Compier Error: '&' on register variable
Rule to Remember:
& (address of ) operator cannot be applied on register variables.

Submit
14. Main(){char not;not=!2;printf("%d",not);}

Explanation

The code snippet initializes a variable 'not' as a character. The expression '!2' evaluates to 0, as the logical NOT operator (!) negates the truth value of the operand. The 'printf' function then prints the value of 'not', which is 0. Therefore, the correct answer is 0.

Submit
15. Main(){int i=10;i=!i>14;Printf ("i=%d",i);} 

Explanation

In the expression !i>14 , NOT (!) operator has more precedence than ‘ >’ symbol. ! is a
unary logical operator. !i (!10) is 0 (not of true is false). 0>14 is false (zero).

Submit
16. # include int one_d[]={1,2,3};main(){int *ptr;ptr=one_d;ptr+=3;printf("%d",*ptr);

Explanation

The given code will result in a compilation error. This is because the code is missing the required header file, which is "stdio.h" for the printf() function.

Submit
View My Results

Quiz Review Timeline (Updated): Dec 3, 2024 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Dec 03, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Aug 18, 2010
    Quiz Created by
    Collegeprojectin
Cancel
  • All
    All (16)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Main(){int i=3;switch(i){default:printf("zero");case 1:...
# include ...
Main(){int *j;{int i=10;j=&i;}printf("%d",*j);} 
Void main(){ int i; char...
Main(){char s[ ]="man";int i;for(i=0;s[ i ];i++)printf("\n%c%c%c%c",s[...
Main(){float me = 1.1;double you = 1.1;if(me==you)printf("I love...
Main(){printf("\nab");printf("\bsi");printf("\rha");}
#includemain(){int i=1,j=2;switch(i){case 1: printf("GOOD");break;case...
Main(){int i=0;for(;i++;printf("%d",i)) ;printf("%d",i);}
#include #define a 10main(){#define a 50printf("%d",a);} 
#define FALSE -1#define TRUE 1#define NULL 0main()...
Main(){int a[10];printf("%d",*a+1-*a+3);
Register int a=2; printf("Address of a = %d",&a); printf("Value...
Main(){char not;not=!2;printf("%d",not);}
Main(){int i=10;i=!i>14;Printf ("i=%d",i);} 
# include int one_d[]={1,2,3};main(){int...
Alert!

Advertisement