You are on page 1of 4

2b) only one variable can be at the left side of an expression

c) It is assumed that arithmetic operators (*) are already present when they are not

e) A single variable can not store more than one values

f) no error

g) There is no exponential operator in C

h) (*) is repeated

3a) Z = ( 8.8 * ( a + b ) * 2 / c - 0.5 +2 * a / ( q + r ) ) / ( ( a + b ) * ( 1 / m ) )

b) X = (-b + ( b * b ) + 2 * (4*a*c) ) / ( 2*a )

5b)

#include<stdio.h>
int main()
{
float km, m, cm, f, in;
printf("Enter distance in kilometers: ");
scanf("%f", &km);
/* calculate the conversion */
m = km * 1000;
cm = km * 1000 * 100;
f = km * 3280.84;
in = km * 39370.08;
printf("The distance in Feet: %f\n", f);
printf("The distance in Inches: %f\n", in);
printf("The distance in Meters: %f\n", m);
printf("The distance in Centimeters: %f\n", cm);
return (0);
}

5c)

#include<stdio.h>
#include<conio.h>
void main()
{
int spanish, math, english, science, art, total;
float percentage;
printf("Enter the marks of Spanish: ");
scanf("%d", &spanish);
printf("Enter the marks of Math: ");
scanf("%d", &math);
printf("Enter the marks of English: ");
scanf("%d", &english);
printf("Enter the marks of Science: ");
scanf("%d", &science);
printf("Enter the marks of Art: ");
scanf("%d", &art);
total = spanish+math+english+science+art;
percentage = total/5;
printf("\nAggregate marks: %d", total);
printf("\nPercentage marks: %0.2f %%", percentage);
getch();
}

d)

#include<Stdio.h>
int main()
{
int C, D, T;
printf("Enter the value of C: ");
scanf("%d", &C);
printf("Enter the value of D: ");
scanf("%d", &D);
C = C+D; //c=30, d=20
D = C-D; //d=10, c=30
C = C-D; //c=20
printf("\n The value of C: %d", C);
printf("\n The value of D: %d", D);
getch();
}
e)

#include<stdio.h>

int main()

    int d1,d2,d3,d4,d5,sum;

    long num;

    printf("Enter a five digit number: ");

    scanf("%ld",&num);

    d1=(num%10);

    d2=(num%100)/10;

    d3=(num%1000)/100;

    d4=(num%10000)/1000;

    d5=(num/1000);

    sum=d1+d2+d3+d4+d5;

    printf("\n The sum of the digits is: %d",sum);

    return 0;

f)

#include<stdio.h>
int main()
{
int number=0, n;
printf("Enter a number: ");
scanf("%d", &n);
while(n!=0)
{
number = number * 10;
number = n % 10 + number;
n = n/10;
}
printf("%d", number);
return 0;
}

g)

#include<stdio.h>
#include<conio.h>
int main()
{
int num, sum, i, number, count=0, n=1;
printf("Enter N Digit's Number: ");
scanf("%d", &num);
number = num;
//get the counter till then we have to run the loop
while(number!=0)
{
number = number/10;
count = count + 1;
}
for(i=1;i<count;i++)
{
n = n * 10; //n = 10
n = n + 1; //n = 11
}
sum = num + n;
printf("Output: %d", sum);
}

Rafid Khan

1720027

You might also like