C programs with solutions

/*————- VARIABLE DECLARATION AND ASSIGNMENT —————*/

 

 

/*————-INVESTMENT PROBLEM USING SCANF—————*/

 

 

 
/*—– USING ARITHMETIC OPERATORS—–*/

# include <stdio.h>
# include <conio.h>
void main()
{
int a, b, c, d;

a = 15;
b = 10;
c = ++a – b;

printf(“a = %d  b = %d  c = %d\n”,a, b, c);

d = b++ +a;
printf(“a = %d  b = %d  d = %d\n”,a, b, d);

printf(“a/b = %d\n”, a/b);
printf(“a%%b = %d\n”, a%b);
printf(“a *= b = %d\n”, a*=b);
printf(“%d\n”, (c>d) ? 1 : 0);
printf(“%d\n”, (c<d) ? 1 : 0);
getch();
}

 

 /*—– EVALUATING EXPRESSIONS—–*/

 

 

 
/*——————- Sum of n terms of 1/n ——————-*/

 

 
/*——————-USING CASTS——————-*/

 

 
/*———- PROGRAM USING IF STATEMENT ——–*/