Posts

Showing posts from October, 2022

C Character Set

 Every language  has some basic element and grammatical rules. Before programming in C, it is must to know the basic elements of the language. These basic elements are character set, variables, datatypes, constants, keywords (reserve word), variable declaration, expression statement etc. All of these are used to construct a C program. C Character set   The characters that are used in C programs are given below. Uppercase and Lowercase letters     A, B, C .................. Z     a, b, c ..................... z Digits  0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Graphic characters Character Name Character Name + Plus sign - Minus * Asterisk % Percentage sign \ Backward slash / Forward slash <   Less than = Equal to sign >   Greater th...

Find out the day of the week from a given date.

            Day of week from a given date W rite a program that finds out the day of the week from a given date. The formula for calculating the day is- day = (y + j + f - h + fh) % 7; j = julian day of the date y = year of given date (in 4 digit) f = int part of (y-1)/4 h = int part of (y-1)/100 fh = int part of (y-1)/400 The value of  variable day tells us the day of week Value of  the variable date Name of day of  week 0 Saturday 1 Sunday 2 Monday 3 Tuesday 4 Wednesday 5 Thursday 6 Friday In the above formula Julian day of a date represent the day of year on which the date fall. Julian day of the 1st Jan is 1 , of 2nd Feb is 33, of 31st Dec is 365 (366 if leap year). Month days Not leap year Leap year ...