Sie sind auf Seite 1von 3

//Avg Marks

#include <stdio.h>
int main()
{
int score_1, score_2, score_3, score_4, score_5;
float avg;

printf("Please enter score 1:\n");//prompts input for score_1


scanf("%d", &score_1);//accepts input for score_1

printf("Please enter score 2:\n");//prompts input for score_


scanf("%d", &score_2);//accepts input for score_2

printf("Please enter score 3:\n");//prompts input for score_3


scanf("%d", &score_3);//accepts input for score_3

printf("Please enter score 4:\n");//prompts input for score_4


scanf("%d", &score_4);//accepts input for score_4

printf("Please enter score 5:\n");//prompts input for score_5


scanf("%d", &score_5);//accepts input for score_5

avg = (score_1 + score_2 + score_3 + score_4 + score_5) / 5.0;//calculates


average score

printf("The average score is %.2f\n", avg);//displays average score

return (0);
}

//MYR TO USD
#include <stdio.h>
int main()
{
float RM, USD, ex_rate;

printf("Please enter RM value: ");//promts input for RM value


scanf("%f", &RM);//accepts input for RM value

printf("Please enter RM to USD exchange rate: ");//prompts input for RM to


USD exchange rate
scanf("%f", &ex_rate);//accepts input for RM to USD exchange rate

USD = RM / ex_rate;//calculates value of RM in USD

printf("RM %f = %.2f USD", RM, USD);//displays value of RM in USD (the.2


limits the output to 2 decimals)

return (0);
}

//add mul subtract


#include <stdio.h>
int main()
{
int integer, ans;

printf("Please enter integer: ");//prompts input for integer


scanf("%d", &integer);//accepts input for integer

ans = (integer + 5) * 2 - 7;//calculates final answer

printf("The final answer is %d\n", ans);//displays final answer

return (0);
}

//Satalite travel
#include <stdio.h>
int main()
{
float sat_height, distance, pi;

printf("Please enter satalite height in km: ");//prompts input for satalite


height
scanf("%f", &sat_height);//accepts input for satalite height

pi = 22 / 7;//sets the value for pi


distance = 2 * pi*(sat_height = 12730);//calculates distance

printf("The distance travelled by the satalite is %.2f km\n",


distance);/*displays the distance travelled by

the satalite the.2 limits the output to 2 decimals*/

return (0);
}

//Acc Bal
#include <stdio.h>
int main()
{
float old_bal, withdrawal, deposit, tax, new_bal;

printf("Please enter current balance: ");//prompts input for old balance


scanf("%f", &old_bal);//accepts input for old balance

printf("Please enter total withdrawals for this month: ");//prompts input for
withdrawals
scanf("%f", &withdrawal);//accepts input for withdrawals

printf("Please enter total deposits for this month: ");//prompts input for
deposits
scanf("%f", &deposit);//accepts input for deposits

tax = (withdrawal + deposit)*0.01;//calculates the federal tax

new_bal = old_bal - withdrawal + deposit - tax;//calculates new balance

printf("The new balance of this account is %.2f \n" , new_bal);//displays the


new balance(the.2 limits the output to 2 decimals)

return (0);
}

Das könnte Ihnen auch gefallen