Ensure the security of your HCL environment by applying the Zero Trust princi...
Class task 4
1. Class task 4
1. Create a program that obtains two numbers from the
user and print the sum difference multiplication, division
and remainder of the two.
#include<stdio.h>
#include<conio.h>
main()
{
int a , b;
printf("enter two numbers n");
scanf("%d%d",&a,&b);
printf("sum %dn",a+b);
printf("multiply %dn",a*b);
printf("division %dn",a/b);
printf("difference %dn",a-b);
printf("reminder of two %dn",a%b);
getch();
}
2. 2. Create a program that obtains user’s age in years and convert it into days
and hours. Your output screenshould be similar to the following:
#include<stdio.h>
#include<conio.h>
main()
{
int a;
int days=365;
int hours=24;
printf("please enter your age in years : n");
scanf("%d",&a);
printf("you are %d days old n",a*days);
printf("while you are %d hours old",a*days*hours);
getch();
}
3. 3. Create a program to prepare your mark sheet. Take the following subject
marks as input and show individual percentage,totalmarks obtain and total
percentage.
#include<stdio.h>
#include<conio.h>
main()
{
printf("subject t marks obtain t total marks t percentage");
int a=70,b=100;
float c=(a*100)/100;
printf("nenglish t %d t t %d tt %.2f",a,b,c);
int d=65,e=100;
float f=(d*100)/100;
printf("nurdu tt %d t t %d tt %.2f",d,e,f);
int g=80,h=100;
float i=(g*100)/100;
printf("nislamiat t %d t t %d tt %.2f",g,h,i);
int sum=a+d+g;
int sum1=b+e+h;
float fl=((c+f+i)*100)/300;
printf("nntotal tt %d tt %d tt %.2f",sum,sum1,fl);
4. getch();
}
4. If a five-digit number is input through the keyboard, write a program to
calculate the sum of its digits. (Hint: Use the modular division operator‘%’)
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d,e,f,g,h,i,j,k,l;
printf("enter a five digit number");
scanf("%d",&a);
b=a%10;
printf("first digit: %d n",b);
c=a/10;
d=c%10;
printf("second digit: %dn",d);
e=c/10;
f=e%10;
printf("third digit: %dn",f);
g=e/10;