IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C# Programming Java Programming
Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

C Programming - Control Instructions

@ : Home > C Programming > Control Instructions > Point Out Errors

Exercise

"Nothing in life is to be feared, it is only to be understood."
- Marie Curie
1. 

Point out the error, if any in the for loop.

#include<stdio.h>
int main()
{
    int i=1;
    for(;;)
    {
        printf("%d\n", i++);
        if(i>10)
           break;
    }
    return 0;
}

A. There should be a condition in the for loop
B. The two semicolons should be dropped
C. The for loop should be replaced with while loop.
D. No error

2. 

Point out the error, if any in the program.

#include<stdio.h>
int main()
{
    int a = 10;
    switch(a)
    {
    }
    printf("This is c program.");
	return 0;
}

A. Error: No case statement specified
B. Error: No default specified
C. No Error
D. Error: infinite loop occurs

3. 

Point out the error, if any in the program.

#include<stdio.h>
int main()
{
    int i = 1;
    switch(i)
    {
        printf("This is c program.");
        case 1:
            printf("Case1");
            break;
        case 2:
            printf("Case2");
            break;
    }
return 0;
}

A. Error: No default specified
B. Error: Invalid printf statement after switch statement
C. No Error and prints "Case1"
D. None of above

4. 

Point out the error, if any in the while loop.

#include<stdio.h>
int main()
{
    int i=1;
    while()
    {
        printf("%d\n", i++);
        if(i>10)
           break;
    }
    return 0;
}

A. There should be a condition in the while loop
B. There should be at least a semicolon in the while
C. The while loop should be replaced with for loop.
D. No error

5. 

Which of the following errors would be reported by the compiler on compiling the program given below?

#include<stdio.h>
int main()
{
    int a = 5;
    switch(a)
    {
	case 1:
	printf("First");

	case 2:
	printf("Second");

	case 3 + 2:
	printf("Third");

	case 5:
	printf("Final");
	break;

    }
    return 0;
}

A. There is no break statement in each case.
B. Expression as in case 3 + 2 is not allowed.
C. Duplicate case case 5:
D. No error will be reported.



© 2008-2011 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Advertise     Contact us: info@indiabix.com     Follow us on twitter!