0% found this document useful (0 votes)
122 views

C Practice Questions

The document contains 22 questions related to C programming concepts like data types, operators, conditional statements, loops, functions etc. It asks the reader to identify errors in code snippets, write programs to solve problems, explain output of programs, and draw flowcharts. Questions range from basic concepts to more advanced topics and include both theoretical and practical questions.

Uploaded by

satyarth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views

C Practice Questions

The document contains 22 questions related to C programming concepts like data types, operators, conditional statements, loops, functions etc. It asks the reader to identify errors in code snippets, write programs to solve problems, explain output of programs, and draw flowcharts. Questions range from basic concepts to more advanced topics and include both theoretical and practical questions.

Uploaded by

satyarth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

Point out the errors in the following c statements if any:

 int =3.14*9;
 name=’john’;
 2*3=area;
 P=2*a+c(2v+4);
 K=rate of interest*amount in rs;

2. What is the output of following programs?

#include<stdio.h>
int main()
{
int x= 11,y=5;
float z=x/y;
printf(“%f”, z);
}

3. What number would be shown on the screen after the following


statements of c are executed?

char ch;
int i;
ch=’G’;
i=ch-‘A’;
printf(“%d”,i);

4. What will be the output of the following programs:

# include <stdio.h>
int main( )
{
int i = 2, j = 3, k, l ;
float a, b ;
k=i/j*j;
l=j/i*i;
a=i/j*j;
b=j/i*i;
printf ( "%d %d %f %f\n", k, l, a, b ) ;
return 0 ; }
# include <stdio.h>
int main( )
{
int a, b, c, d ;
a=2%5;
b = -2 % 5 ;
c = 2 % -5 ;
d = -2 % -5 ;
printf ( "a = %d b = %d c = %d d = %d\n", a, b, c, d ) ;

5. Write a C program to print your name, date of birth and mobile


number. 

Expected Output:

Name : John
DOB : July 14, 1975
Mobile : 9999999999

6. Write a C program that accepts two item’s weight (floating


points' values ) and number of purchase (floating points' values)
and calculate the average value of the items.

Test Data :
Weight - Item1: 15
No. of item1: 5
Weight - Item2: 25
No. of item2: 4
Expected Output:
Average Value = 19.444444

7. Write a C program to swap two numbers or exchange values of


two variables.

8. Write a C program to read an amount (integer value) and break


the amount into smallest possible number of bank notes.
Note: The possible banknotes are 100, 50, 20, 10, 5, 2 and 1.

9. Print value of a and b. Where a is int type and b is floating type.


a=2/9 b=2/9
a=2.0/9 b=2.0/9
a=2/9.0 b=2/9.0
a=2.0/9.0 b=2.0/9.0
a=9.0/2 b=9.0/2
a=9/2.0 b=9/2.0
a=9/2 b=9/2
a=9.0/2.0 b=9.0/2.0

10. A farmer wants to fence with 3 rounds of wire in his rectangular


plot of length 20 meters and breadth 15 meters. Calculate total wire
to be purchased. If the cost per meter of wire is 400 rupees. Also
calculate total cost of fencing.

11. Write a C program to read the age of a candidate and determine


whether it is eligible for casting his/her own vote.

12. Write a C program to find the largest of three numbers

13. Write a C program to accept a coordinate point in a XY


coordinate system and determine in which quadrant the coordinate
point lies.

15. Write a program in C to read any day number in integer and


display day name in the word using switch case.

16. Write a program in C which is a Menu-Driven Program to


perform a simple calculation.

17. Write a c program to input a 4 digit number and print


sum of digits.

18. Write a c program to input a 4 digit number and print its


reverse.

19.While purchasing certain items, a discount of 10% is


Offered if the quantity purchased is more than 1000. If
quantity and price per item are input through the keyboard,
write a program to calculate the total expenses. Also draw
its flow chart.

20. In a company an employee is paid as under:

If his basic salary is less than Rs. 1500, then HRA = 10% of
basic salary and DA = 90% of basic salary. If his salary is
either equal to or above Rs. 1500, then HRA = Rs. 500 and
DA = 98% of basic salary. If the employee's salary is input
through the keyboard write a program to find his gross
salary. Also draw its flow chart.

21. If cost price and selling price of an item are input


through the keyboard, write a program to determine
whether the seller has made profit or incurred loss. Also
determine how much profit he made or loss he incurred.

22. Point out the errors, if any, in the following programs:

# include <stdio.h>
int main( )
{
float a = 12.25, b = 12.52 ;
if ( a = b )
printf ( "a and b are equal\n" ) ;
return 0 ;
}

# include <stdio.h>
int main( )
{
if ( 'X' < 'x' )
printf ( "ascii value of X is smaller than that of x\n" ) ;
return 0 ;
}

# include <stdio.h>
int main( )
{
int x = 10 ;
if ( x >= 2 ) then
printf ( "%d\n", x ) ;
return 0 ;
}

# include <stdio.h>
int main( )
{
int x = 10, y = 15 ;
if ( x % 2 = y % 3 )
printf ( "Carpathians\n" ) ;
return 0;
}

#include <stdio.h>
int main( )
{
int i = 4, j = -1, k = 0, w, x, y, z ;
w = i || j || k ;
x = i && j && k ;
y = i || j && k ;
z = i && j || k ;
printf ( "w = %d x = %d y = %d z = %d\n", w, x, y, z ) ;
return 0 ;
}

You might also like