Showing posts with label C Basic. Show all posts
Showing posts with label C Basic. Show all posts

Wap to print line or draw line after text without using graphics


/*Wap to print line or draw line after text without using graphics*/
#include<stdio.h>
#include<conio.h>

void drawline();

void main()
{
 clrscr();

 drawline();

 printf("SMIT");

 drawline();

 getch();
}

void drawline()
{
 int i;
 printf("\n");
 for(i=0;i<10;i++)
  printf("-");
 printf("\n");

}

WAP to illustrate the use of CONTINUE and BREAK statement using IF Else

/*WAP to illustrate the use of CONTINUE and BREAK statement using IF Else*/
#include<stdio.h>
#include<conio.h>

void main()

{
 int x=5,y=7,z=8;
 clrscr();
 for(;50<100;x++,y++)
 {
 while(y>=x)
 {
 printf("\n%d%d%d",x,y,z);
 y--;
 break;
 }
 if(x==5)
  break;
 else
  continue;
 }
 getch();
}

WAP to illustrate the equal to and not equal to operator with if else

/*WAP to illustrate the equal to and not equal to operator with if else*/
#include<stdio.h>
#include<conio.h>

void main()

{
 int x,y;
 clrscr();
 printf("enter the value of x & y:\n");
 scanf("%d %d",&x,&y);

 if(x==0&&y==0)
  {
   printf("the point is origin");
  }
 else if(x==0&&y!=0)
  {
   printf("the point is on y-axis");
  }
 else if(y==0&&x!=0)
  {
   printf("the point is on x-axis");
  }
 else
   printf("the point is not on any axis");
 getch();
}

WAP that give exampple of command line arguments


#include <stdio.h>
 
main(int argc, char *argv[])
{
   int c;
 
   printf("Number of command line arguments passed: %d\n", argc);
 
   for ( c = 0 ; c < argc ; c++)
      printf("%d. Command line argument passed is %s\n", c+1, argv[c]);
 
   return 0;
}

WAP that illustrate the increament operator


#include <stdio.h>
 
main()
{
   int value = 1;
 
   while(value<=3)
   {
      printf("Value is %d\n", value);
      value++;
   }
 
   return 0;
}

WAP to cheak whether number entered by user is equal to one or not


#include <stdio.h>
 
main()
{
   int x = 1;
 
   if ( x == 1 )
      printf("x is equal to one.\n");
   else
      printf("For comparison use == as = is the assignment operator.\n");
 
   return 0;
}

WAP to illustrate the functions SCANF() & PRINTF()


#include <stdio.h>
 
main()
{
   int number;
 
   printf("Enter an integer\n");
   scanf("%d",&number);
 
   printf("Integer entered by you is %d\n", number);
 
   return 0;
}