0% found this document useful (0 votes)
2 views2 pages

exercise for C

The document contains multiple C programming code snippets demonstrating variable manipulation, conditional operations, and output using printf. Each snippet illustrates different concepts such as variable swapping, finding maximum values, assignment and comparison operations, logical operators, and post/pre-increment behavior. The code examples highlight the importance of understanding operator precedence and the effects of increment/decrement operations on variable values.

Uploaded by

landeparth93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

exercise for C

The document contains multiple C programming code snippets demonstrating variable manipulation, conditional operations, and output using printf. Each snippet illustrates different concepts such as variable swapping, finding maximum values, assignment and comparison operations, logical operators, and post/pre-increment behavior. The code examples highlight the importance of understanding operator precedence and the effects of increment/decrement operations on variable values.

Uploaded by

landeparth93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

int main(void)

{
int a = 5, b =10, temp;
temp =a , a =b, b = temp;
printf("a = %d, b = %d\n",a,b);
return 0;
}

int main(void)
{
int a = 10, b = 3, max;
a>b ? max = a : max = b;
printf("%d\n",max);
return 0;
}

int main(void)
{
int a = 5, b = 6;
printf("%d\t",a = b);
printf("%d\t",a == b);
printf("%d %d\n",a,b);
return 0;
}

int main(void)
{
int a = 3, b = 4, c = 3, d = 4, x,y;
x = (a=5) && (b = 7 );
y = (c = 5) || (d = 8);
printf(" a = %d, b = %d, c = %d, x = %d, y = %d\n",a,b,c,d,x,y);

x = (a == 6) && ( b = 8);
y = (c == 6) || (d = 10);

printf("a = %d, b = %d, c=%d, d= %d, x= %d, y =%d\n",a,b,c,d,x,y);


return 0;
}

int main(void)
{
int a = 10;
a = a++;
a = a++ * a--;
printf("%d\n",a);
printf("%d\n",a++ * a++);
return 0;
}

int main(void)
{
int a = 2, b =2 , x,y;
x = 4 * (++a * 2 + 3);
y = 4 * (b++ * 2 + 3);
printf("a =%d, b = %d, x =%d, y =%d\n",a,b,x,y);
return0;
}

You might also like