In this article, we are gonna to discuss questions to expert using C operators
Before doing the tutorial 08, watch this video to get an idea about Precedence & Associativity of Operators .
Here you can find the tutorial 08 questions pdf to practice C operators ;
https://www.thecn.com/uploads/646a63/646a6321c2ab142a210164a5/s3/NjMzNWEyM2JhOGE1NWUxZjk5NWIzNTcxLzY0NmE2MzFlYTQ2ODBiOTQzZTAxMDk5YS9JQ1QxNDAyX1R1dG9yaWFsXzA4LnBkZg/d98e205dae89b6a10ee38cce99845dcf.pdf
1.Type in and run the all programs presented in lecture note 7 and 8. Briefly describe the theory/ concept you learned from these programs separately.
- Defining the terms operators, operands, operator precedence, and associativity.
- Describing operators in C programming language.
- Practicing the effect of different operators in the C programming language.
- Justifying evaluation of expressions in programming.
- Applying taught concepts for writing programs.
2. Write a program to evaluate the polynomial shows here.
3x 3 - 5x 2 + 6 for x = 2.55
3. Write a program that evaluates the following expression and displays the results (remember to use exponential format to display the result):
(3.31 × 10-8 × 2.01 × 10-7) / (7.16 × 10-6 + 2.01 × 10-8)
Answer
#include <stdio.h>
int main()
{
double number1 = 3.31e-8;
double number2 = 2.01e-7;
double number3 = 7.16e-6;
double number4 = 2.01e-8;
double result = (number1 * number2) / (number3 + number4);
printf("Result: %e\n", result);
return 0;
}
4. To round off an integer i to the next largest even multiple of another integer j, the following formula can be used:
Next_multiple = i + j - i % j
For example, to round off 256 days to the next largest number of days evenly divisible by a week, values of i = 256 and j = 7 can be substituted into the preceding formula as follows:
Next_multiple = 256 + 7 - 256 % 7
= 256 + 7 - 4
= 259
Write a program to find the next largest even multiple for the following values of i and j: (Use keyboard to input values for i and j)
Answer
#include <stdio.h>
int main(){
int i,j,next_multiple;
printf("Enter the value of an i:");
scanf("%i",&i);
printf("\nEnter the value of an j:");
scanf("%i",&j);
next_multiple=i+j-(i%j);
printf("\nNext largest even multiple=%i",next_multiple);
return 0;
}
5.Write a program to input the radius of a sphere and to calculate the volume of the sphere.
Volume = 4/3*pi*radius3
Answer
#include <stdio.h>
int main()
{
float r,v;
const PI=3.14;
printf("Enter the radius of the sphere:");
scanf("%f",&r);
v = (4/3)*PI* r*r*r;
printf("Volume of the sphere:%f",v);
return 0;
}
7. Write a program to input your mid term marks of a subject marked out of 30 and the final exam marks out of 100. Calculate and print the final results.
Final Result = Mid Term + 70% of Final Mark
Answer
#include <stdio.h>
int main() {
int midTermMarks, finalExamMarks;
double finalResult;
printf("Enter mid-term marks [out of 30]: ");
scanf("%d", &midTermMarks);
printf("Enter final exam marks [out of 100]: ");
scanf("%d", &finalExamMarks);
finalResult = midTermMarks + 0.7 * finalExamMarks;
printf("Final Result: %.2f\n", finalResult);
return 0;
}
- 8. Input the source file and destination file name as command line arguments and print the following message to standard output: “Copy the details in <file name 1> to <file name 2> at 23.59.59”
BMS Group Members :
· 01)M.G. Janeesha Sinty
Registration number-ICT/21/22/043
CN- JG1539
· 02)R.D. Malsha Nethmini Premathilaka
Registration number- ICT/21/22/085
CN- MN1032
· 03)S. Basuru Rupasinghe
Registration number- ICT/21/22/132
CN- SR1777