0% found this document useful (0 votes)
5 views1 page

C Programming Date and Arithmetic Exercises

The document contains two exercises in C programming. Exercise 3 demonstrates how to read and format dates using both without and with operators. Exercise 4 performs basic arithmetic operations on two integers and displays the results.

Uploaded by

kailex44
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

C Programming Date and Arithmetic Exercises

The document contains two exercises in C programming. Exercise 3 demonstrates how to read and format dates using both without and with operators. Exercise 4 performs basic arithmetic operations on two integers and displays the results.

Uploaded by

kailex44
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Exercise:3(tp02)

#include <stdio.h>

void main()
{
int date,dd, mm, yyyy;
printf("please enter the date witouth operators -\n");
scanf("%2d%2d%4d",&dd, &mm, &yyyy);
printf("the date is %2d/%2d/%4d\n",dd, mm, yyyy);
printf("enter your date with operator -");
scanf("%2d-%2d-%4d",&dd,&mm,&yyyy);
printf("the date is %2d/%2d/%4d",dd,mm,yyyy);
// I have learned how do use operator %nd from this exercise so
i can take two digits from an integer.

Exercise:4(tp01)

#include <stdio.h>

void main()
{
int a,b,sum,diff,product,divison,remainder;
b=3;
a=18;
sum=a+b;
diff= a-b;
product=a*b;
divison=a/b;
remainder=a%b;
printf("%d+%d=%d\n%d-%d=%d\n%d*%d=%d\n%d/%d=%d\n%d%%
%d=%d",a,b,sum,a,b,diff,a,b,product,a,b,divison,a,b,remainder);
}

You might also like