-->

program to get total and percentage of a student

// program to get total and percentage of a student
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int english,maths,physics,chemistry;
float total,percentage;
printf(“enter marks of different subjects \n”);
scanf(“%d%d%d%d”,&english,&maths,&physics,&chemistry);
total=english+maths+physics+chemistry;
percentage=(float)total/4; //called type casting to convert total/4 into floating value
printf(“the total marks is=%f\ and percentage=%f\n”,total,percentage);
getch();
}

note:
you can also use like,
percentage=(float)(total/4);
 or
percentage=float(total/4);
you get same output.

program to get value of f(x)

// program to get value of f(x)=x2+2x+3
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float x,f_x;
printf(“enter x \n”);
scanf(“%f”,&x);
f_x=(pow(x,2)+2*x+3); //pow() function exists inside math.h
printf(“the result is=%f\n”,f_x);
getch();
}

input and output programs

continued.......

P19)write a program to get value of  f(x)=x2+2x+3.Here, x is a variable.
                                                                                                                  solution
P20)Write a program to get total and percentage of a student whose marks in different subjects are given below.
                                                                                                       
subjects marks
english45
maths65
physics45
chemistry45
                                                                                                                   solution

P21)Write a program to get value of quadratic equation ax2+bx+c.Here, symbols have as usual meaning. (use simple method)                                                              
                                                                                                                   solution

P22)Write a program to convert number of days into year,months and days.
                                                                                                                    solution

P23)Write a program to convert number of seconds into hour,minutes and seconds.
                                                                                                                    solution

P24)write a program to know ascii value of entered character.
                                                                                                                    solution