Earn by twitter on twivert

Sign up for PayPal and start accepting credit card payments instantly.

Tuesday, September 14, 2010

WAP to Use of # pragma 2


/*WAP to Use of # pragma */
/* Pogram to supress specific warning */
#include<stdio.h>
#include<conio.h>
#pragma warn -rvl /* return value */
#pragma warn -par /* parameter not used */ 
#pragma warn -rch /* unreachable code */

int  f1( )
{
 int  a = 5 ;
}

void  f2 ( int  x )
{
 printf ( "\nInside f2" ) ;
}

int  f3( )
{
 int  x = 6 ;
 return x ;
 x++  ;
}

void  main( )
{
 f1( ) ;
 f2 (  7 ) ;
 f3( ) ;
 getch();
}

WAP to Use of #pragma


/*WAP to Use of #pragma */
/* Program to change execution of functions */
#include<stdio.h>
#include<conio.h>
void fun1( ) ;
void fun2( ) ;

#pragma startup fun1
#pragma exit fun2

main( )
{
 printf ( "\nInside maim" ) ;
 getch();
}

void fun1( )
{
 printf ( "\nInside fun1" ) ;
}

void fun2( )
{
 printf ( "\nInside fun2" ) ;
}

WAP to Multiple line in macros expansion


/*WAP to Multiple line in macros expansion*/
/* Program to draw horizontal & vertical line */
#include<stdio.h>
#include<conio.h>
#define HLINE   for ( i = 0 ; i < 79 ; i++ ) \  
                             printf ( "%c", 196 ) ;

#define VLINE( X, Y )  {\gotoxy ( X, Y ) ; \
       printf ( "%c", 179 ) ; \
     }
main( )
{
 int  i, y ;
 clrscr( ) ;

 gotoxy ( 1, 12 ) ;
 HLINE

 for ( y = 1 ; y < 25 ; y++ )
  VLINE ( 39, y ) ;
 getch();
}


WAP to Macros expansion with arguments


/*WAP to Macros expansion with arguments */
/* Program to test whether entered character is digit */
#define ISDIGIT(y) ( y >= 48 && y <= 57 )
main( )
{
 char  ch ;

 printf ( "Enter any digit " ) ;
 scanf ( "%c", &ch ) ;

 if ( ISDIGIT ( ch ) )
  printf ( "\nYou entered a digit" ) ;
 else
  printf ( "\nIllegal input" ) ;
       getch();
} 


WAP to use Macros expansion with arguments


/*WAP to use Macros expansion with arguments */
#include<stdio.h>
#include<conio.h>
#define AREA(x) ( 3.14 * x * x )
main( )
{
 float  r1 = 6.25, r2 = 2.5, a ;
 
 a = AREA ( r1 ) ;
 printf ( "\nArea of circle = %f", a ) ;
 a = AREA ( r2 ) ;
 printf ( "\nArea of circle = %f", a ) ;
       getch();
}

WAP to # define statement used to replace entire C statement


/*WAP to # define statement used to replace entire C statement */
#include<stdio.h>

#define FOUND printf ( "The Yankee Doodle Virus" ) ;
main( )
{
 char  signature ;

 if ( signature == 'Y' ) 
  FOUND
 else
  printf ( "Safe... as yet !" ) ;
 getch();
}


WAP to Nested macro expansion


/*WAP to Nested macro expansion*/
#include<stdio.h>
#include<conio.h>
#define AND &&
#define ARANGE ( a > 25 AND a < 50 )
main( )
{
 int  a = 30 ;

 if ( ARANGE )
  printf ( "within range" ) ;
 else
  printf ( "out of range" ) ;
 getch();
}

WAP to use Macro expansion Logical operator


/*WAP to use Macro expansion Logical operator*/
#include<stdio.h>
#include<conio.h>
#define AND &&
#define OR  ||
main( )
{
 int  f = 1, x = 4, y = 90 ;

 if ( ( f < 5 ) AND ( x <= 20 OR y <= 45 ) )
  printf ( "\nYour PC will always work fine..." ) ;
 else
  printf ( "\nIn front of the maintenance man" ) ;
 getch();
}

WAP to Use of macro expansion2


/*WAP to Use of macro expansion*/
#include<stdio.h>
#include<conio.h>
#define PI  3.1415
main( )
{
 float  r = 6.25 ;
 float  area ;

 area = PI * r * r ;
 printf ( "\nArea of circle = %f", area ) ;
 getch();
}

WAP to Use of macro expansion


/*WAP to Use of macro expansion*/
#include<stdio.h>
#include<conio.h>
#define UPPER 25
main( )
{
 int  i ;
 for ( i = 1 ; i <= UPPER ; i++ )
  printf ( "\n%d", i ) ;
}

WAP to Use of continue keyword in for loop


/*WAP to Use of continue keyword in for loop */
#include<stdio.h>
#include<conio.h>
main( )
{
 int   i, j ;

 for ( i = 1 ; i <= 2 ; i++ )
 {
  for ( j = 1 ; j <= 2 ; j++ )
  {
   if ( i == j )
    continue ;

   printf ( "\n%d %d\n", i, j ) ;
  }
 }
 getch();
}

Execution of a loop an unknown number of times


/* Execution of a loop an unknown number of times */
#include<stdio.h>
#include<conio.h>
main( )
{
 char  another ;
 int  num ;
 do
 {
  printf ( "Enter a number " ) ;
  scanf ( "%d", &num ) ;
  printf ( "square of %d is %d", num, num * num ) ;
  printf ( "\nWant to enter another number y/n " ) ;
  scanf ( " %c", &another ) ;
 } while ( another == 'y' ) ;
 getch();
}


WAP to Demonstration of nested loops


/*WAP to Demonstration of nested loops */
#include<stdio.h>
#include<conio.h>
main( )
{
 int   r, c, sum ;
 for ( r = 1 ; r <= 3 ; r++ )  /* outer loop */
 {
  for ( c = 1 ; c <= 2 ; c++ )  /* inner loop */
  {
   sum = r + c ;
   printf ( "r = %d c = %d sum = %d\n", r, c, sum ) ;
  }
 }
 getch();
}


WAP to Shape


/*WAP to Shape*/
#include<stdio.h>
#include<conio.h> 
void main()
{
int i,j,n;
clrscr();  //clear screen

for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
printf("%d ",i);
printf("\n");
}
getch();
}

WAP to shap


/*WAP to shap3*/
#include<stdio.h>
#include<conio.h> 
void main()
{
 int i,j;
clrscr();   //clear screen
for(i=5;i>=1;i--)   //loop starts from n for row
{
for(j=1;j<=i;j++)  // loop executes i times for colom
printf("%d",j);   // print j
printf("\n");   // goto next line
}
getch();
}

WAP to Demonstrate casts


/*WAP to Demonstrate casts*/
class Conversion {
public static void main(String args[]) {
byte b;
int i = 257;
double d = 323.142;
System.out.println("\\nConversion of int to byte.");
b = (byte) i;
System.out.println("i and b " + i + " " + b);
System.out.println("\\nConversion of double to int.");
i = (int) d;
System.out.println("d and i " + d + " " + i);
System.out.println("\\nConversion of double to byte.");
b = (byte) d;
System.out.println("d and b " + d + " " + b);
}
getch();
}

WAP to Demonstrate dynamic initialization


/*WAP to Demonstrate dynamic initialization*/
class DynInit {
public static void main(String args[]) {
double a = 3.0, b = 4.0;
// c is dynamically initialized
double c = Math.sqrt(a * a + b * b);
System.out.println("Hypotenuse is " + c);
}
getch();
}

WAP to Demonstrate boolean values


/*WAP to Demonstrate boolean values*/
class BoolTest {
public static void main(String args[]) {
boolean b;
b = false;
System.out.println("b is " + b);
b = true;
System.out.println("b is " + b);
// a boolean value can control the if statement
if(b) System.out.println("This is executed.");
b = false;
if(b) System.out.println("This is not executed.");
// outcome of a relational operator is a boolean value
System.out.println("10 > 9 is " + (10 > 9));
}
}

ADS

How to earn online

How to earn online:
Step - 1 :
signup for PayPal, to recieve your online earning
click here:
https://www.paypal.com/in/mrb/pal=CZ7224TZBMCBL
step - 2 : Singup these 4 sites & earn & enjoy! Read site to know how to earn.
1. trekpay
Earn up to $0.02 (2 cents) per click.
http://www.trekpay.com/?ref=34690
2. neobux
Earn up to $0.02 (2 cents) per click.
Click here:
http://www.neobux.com/?r=Moneyearner786

AddMe

Bookmark and Share