Ad

Chapter - 2: C Instructions

What will be the output of the following programs.


Ad
E
Sections
1
Exercises

(a)

#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", k, l, a, b ) ; 
	return 0;
}

Output:

0 2 0.0 2.0


(b)

#include<stdio.h>
int main( ) 
{ 
	int  a, b ;
	a = -3 - - 25 ;
	b = -3 - - ( - 3 ) ;
	printf ( "a = %d b = %d", a, b ) ;
	return 0;
}

Output:

a = 22 b = -6


(c)

#include<stdiuo.h>
int main()
{
	float a = 5,  b = 2;
	int c;
	c = a % b;
	printf("%d", c);
	return 0;
}

Output:

Error: % Operator cannot be used with floats.


(d)

#include<stdio.h>
int main()
{
	printf( "nn \n\n nn\n" );
	printf ( "nn /n/n nn/n" );
	return 0;
}

Output :

nn 

 

 nn

nn /n/n nn/n


(e)

#include<stdio.h>
int main()
{
	int a, b ; 
	printf("Enter values of a and b"); 
	scanf( "\%d %d", &a, &b ); 
	printf( "a  = %d b = %d", a, b );
	return 0;
}

Output:

[Same as the user input]

Ad

© 2024 Garbage Valuegarbage value logo