C Practice Questions
C Practice Questions
int =3.14*9;
name=’john’;
2*3=area;
P=2*a+c(2v+4);
K=rate of interest*amount in rs;
#include<stdio.h>
int main()
{
int x= 11,y=5;
float z=x/y;
printf(“%f”, z);
}
char ch;
int i;
ch=’G’;
i=ch-‘A’;
printf(“%d”,i);
# 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 ) ;
Expected Output:
Name : John
DOB : July 14, 1975
Mobile : 9999999999
Test Data :
Weight - Item1: 15
No. of item1: 5
Weight - Item2: 25
No. of item2: 4
Expected Output:
Average Value = 19.444444
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.
# 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 ;
}