0% found this document useful (0 votes)
37 views3 pages

C Programs

The document provides instructions to write a C program that prompts the user to enter

Uploaded by

Tamali Ganguly
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views3 pages

C Programs

The document provides instructions to write a C program that prompts the user to enter

Uploaded by

Tamali Ganguly
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

1) Find the output :

#include <stdio.h>

void main()
{
/* declarations */
int a, b, c, d, e;

/* fill variable a */
a = 10;

/* modify variable a few times*/


a = 20;
a = 10 + a;
a = a + a + 2;
a = 2 + a;

/* a few more assignments */


b = a;
c = b = 5;
c = 10 + a;
d = a + a + 2;
e = 20 + a;
a = a - b + c;

/* the final values are... */


printf ("a:%4d\n b:%4d\n c:%4d\n d:%4d\n e:
%4d\n", a, b, c, d, e);
}

2) void main()
{
int a, b;

a = 5;

/* increment (++) */
/* a is incremented by 1 */
++a;
printf ("After ++a, a is now %d\n", a);

/* a is once more incremented by 1 */


a++;
printf ("After a++, a is now %d\n", a);

/* a is incremented but b gets the current a */


b = a++;
printf ("After b=a++, a is now %d and b is
%d\n", a, b);

/* a is incremented and b gets the incremented a


*/
b = ++a;
printf ("After b=++a, a is now %d and b is
%d\n", a, b);

/* decrement (--) */
/* a is decremented by 1 */
--a;
printf ("After --a, a is now %d\n", a);

/* a is once more decremented by 1 */


a--;
printf ("After a--, a is now %d\n", a);

/* a is decremented but b gets the current a */


b = a--;
printf ("After b=a--, a is now %d and b is
%d\n", a, b);

/* a is decremented and b gets the decremented a


*/
b = --a;
printf ("After b=++a, a is now %d and b is %d\n", a, b);
}
3) write a program in c which gives the following output in the
screen –

What is the current temperature?


If the temperature is equal or above 20 , it will print –
“It is quite warm”
If it is less than 20, it will print –
“It is quite cool”.

4)

You might also like