Getting Started with Basic C Programs
(a)
# include<stdio.h>
void 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 " , k , l , a , b ) ;
}
Output :
0 2 0.000000 2.000000
( b )
# include<stdio.h>
void main ( )
{
int a , b ;
a= - 3 - - 3 ;
b = - 3 - - ( - 3 );
printf ( " a = %d b= %d " , a ,b ) ;
}
Output :
a = 0 b = - 6
( c )
# include<stdio.h>
void main ( )
{
float a =5 , b = 2;
int c;
c = a % b ;
printf ( " %d , c ) ;
}
Output :
Error.Mod ( % ) operator cannot be used on floats
( d )
# include <stdio.h>
void main ( )
{
printf ( " n n \n \n n n \n" ) ;
printf ( " n n /n / n n /n " ) ;
}
Output :
n n
n n /n /n n n /n
( e)
C language has been developed by
1. Ken thompson
2. Dennis Ritchie
3.Peter Northon
4.Martin Ritchards
Answer :
2. Dennis Ritchie
( f )
C can be used on
1. Only MS - DOS operating system
2. Only Linux operating system
3. Only Windows operating system
4. All the above
Answer :
4. All the above
( g )
C programming are converted into machine language with the help of
1. An Editor
2. A compiler
3. An operating system
4. None of the above
Answer :
2. A compiler
( h )
Which of the following statement is wrong
1. mes = 123.56 ;
2. con = 'T' * 'A' ;
3. this = 'T' * 20 ;
4. 3 + a = b ;
Answer :
4. 3 + a = b ;
( i )
If ' a ' is an integer variable, a = 5/2 ;will return a value
1. 2.5
2. 3
3. 2
4. 0
Answer :
3. 2
( j )
The expression x= 4 + 2 % - 8 evaluates to
1. -6
2. 6
3. 4
4. None of the above
Answer :
6
( k)
In C a variable cannot contain
1. Blank spaces
2. Hyphen
3. Decimal point
4. All the above
Answer :
4. All the above ( a ) .
The expression, a = 7 / 22 * ( 3.14 + 2 ) * 3 / 5 ;
evaluates
1) 8.28
2) 6.28
3) 3.14
4) 0
( b )
The maximum value that an integer constant can have is
1) -32767
2) 32767
3) 1.7014e + 38
4) -1.7014e + 38
( c )
In b = 6.6 / a + 2 *n ; which operation will be performed first ?
1) 6.6 / a
2) a + 2
3) 2 * n
4) Depends upon compiler