Translate

Labels

Sunday, 27 October 2013

RIGHT ANGLED TRIANGLE OF STARS

Program to print 

*********
********
*******
******
*****
****
***
**
*

 main()
{
int i,j,n;
clrscr();
scanf("%d",&n);
for(i=0;i<=n;)
{
for(j=0;j<n;j++)
{
printf("*");
}
printf("\n");
n--;
}
getch();
}

C PUZZLES

Assignment Operators

What dopes the following program print?
#define PRINTX printf("%d\n",x)

main()
{
int x=2,y,z;
x*=3+2;
PRINTX;
x*=y=z=4;
PRINTX;
x=y==z;
PRINTX;
x==(y=z);
PRINTX;
}


Explanation


Tuesday, 8 October 2013

RIGHT ANGLED TRIANGLE OF STARS

Program to print Right Angled Triangle of Stars

*
**
***
****
*****

for(i=0;i<=n;i++)
{

Tuesday, 13 August 2013

C PUZZLES

Basic Arithmetic Operators

mian()
{
int x;
x=- 3 + 4 * 5 -6;    /*1*/
printf("%d\n",x);
x=3 + 4 % 5 - 6;     /*2*/
printf("%d\n",x);
x=- 3 *4 %-6 / 5;    /*3*/
printf("%d\n",x);
x=(7+6)%5/2;         /*4*/
printf("%d\n",x);
}


1.x=- 3 + 4 * 5 -6;             by reading the precedence table

   x=(- 3) + 4 * 5 -6;          The highest level operator in the expression is the unary -. We'll use                                                                parentheses indicate the order of binding operands to operators. 
   x=(- 3) + (4 * 5) -6;        Next highest in the expression is *.

  

Friday, 2 August 2013

PROGRAM TO FIND GCD OF TWO INTEGERS

GCD
mian()
{
int a,b ;
printf("Enter two positive integers :\n");
scanf("%d%d",&a,&b);
printf("GCD of %d and %d is %d\n",a,b,gcd(a,b));
}
gcd(int a,int b)
{
if(a)
return(b?gcd(b,a%b):a);
else
return b;
}



OUTPUT
Enter two positive integers
24   36
GCD of 24 and 36 is 12

Saturday, 13 July 2013

PASSING 2-D ARRAY TO A FUNCTION

There are three ways in which we can pass a 2-D array to a function.these are illustrated in the following program.

main()
{
int a[3][4]={1,2,3,4,5,6,7,8,9,8,7,6};
clrscr();
display(a,3,4);
show(a,3,4);
print(a,3,4);
}


Tuesday, 2 July 2013

GET IP ADDRESS USING C PROGRAM

#include<stdlib.h>
int main()
{
system("C:\\windows\\system32\\ipconfig");
return 0;
}