User can enter the calender entry i.e date,month and year. C Program will print the day of that date.
How to Input Password in C ? [crayon-60940c7144445502266670/] Output : [crayon-60940c7144450625236003/] Explain ? [crayon-60940c7144455814329469/] Accept Character without Echo [ without displaying on Screen ] getch will accept character and store it in "ch" [crayon-60940c714445a396707004/] ASCII Value of "Enter Key" is 13 Stop Accepting Password Characters after "Enter" Key. [crayon-60940c714445f818425222/] ASCII Value of "BACKSPACE" is 8 After hitting "backspace"following actions should be carried out - Cursor Should be moved 1 character back. Overwrite that character by "NULL". After Writing NULL again cursor is moved 1 character ahead so again move cursor 1 character back . Decrement Current [...]
Problem Statement : Write a C Program to Find the Number of Digits in an entered number ? [crayon-60940c7144c8a340250179/] Output: [crayon-60940c7144c92341637617/]
Add Two Numbers Using Inline Assembly Language ??? [crayon-60940c714501d116402614/] Assembly Language can be Written in C . C Supports Assembly as well as Higher Language Features so called "Middle Level Language". As shown in above Program , "asm" Keyword is written to indicate that "next followed instruction is from Assembly Language". [crayon-60940c7145028212557277/] Opening Curly brace after "asm" keyword tells that it is the "Start of Multiple Line Assembly Statements" i.e "We want to Write Multiple Instructions" Above Program Without "Opening and Closing Brace" can be written [...]
Accept Paragraph using scanf in C [crayon-60940c7145437122894899/] Output :[Press Tab to Stop Accepting Characters ] [crayon-60940c7145442110449434/] How ? [crayon-60940c7145447808053244/] Here scanf will accept Characters entered with spaces. It also accepts the Words , new line characters . %[^\t]s represent that all characters are accepted except tab(t) , whenever t will encountered then the process of accepting characters will be terminated. Drawbacks : Paragraph Size cannot be estimated at Compile Time It’s vulnerable to buffer overflows. How to Specify Maximum Size to Avoid Overflow ? [crayon-60940c714544d473592261/] Output : [crayon-60940c7145452296232699/] Download PDF : Click Here
Part 1 : Printf Hello word in C without using semicolon [only ones ] [crayon-60940c71458a2338080204/] Output : [crayon-60940c71458a8129393124/] Part 2 : Printf Hello word in C without using semicolon [infinite times] [crayon-60940c71458ac225919793/] Part 3 : Printf Hello [Using Switch] [crayon-60940c71458af951037199/] Part 4 : Using Else-if Ladder [crayon-60940c71458b2097220328/] Part 5 : Printf Hello [Using While and Not] [crayon-60940c71458b5786521417/] Part 6 : Using #define [crayon-60940c71458b7366526308/]
nested Printf statements : Example 1 [crayon-60940c7145d41889364071/] Output : [crayon-60940c7145d48612675192/] How ? "abcdefghijklmnopqrstuvwxyz" will be first Printed while executing inner printf Total Length of the "abcdefghijklmnopqrstuvwxyz" is 26 So printf will return total length of string It returns 26 to outer printf This outer printf will print 26
Printf inside printf in C : Example 1 [crayon-60940c71460a3381619861/] Output : [crayon-60940c71460aa019022785/] How ? Firstly Inner printf is executed which results in printing 1324 This Printf Returns total number of Digits i.e 4 and second inner printf will looks like [crayon-60940c71460ad469008419/] It prints 4 and Returns the total number of digits i.e 1 (4 is single digit number ) [crayon-60940c71460b0356926733/] It prints simply 1 and output will looks like 132441 Rule : Inner printf returns Length of string printed on screen to the outer printf
C program to reverse the digits of a number ? [ In 3 Steps ] Problem Statement : Reversing the digits of number without using mod (%) Operator ? Prerequisite : Atoi function Sprintf function [crayon-60940c714686f853284245/] Output : [crayon-60940c7146876507294822/] Explain Logic : Step 1 : Store Number in the Form of String Sprintf function sends formatted output to string variable specified Number will be stored in String variable "str" [crayon-60940c7146879544937822/] Step 2 : Reverse the String Using Strrev Function Strrev will reverse String eg "1234" will be reversed as "4321" [crayon-60940c714687c654318690/] Step 3 : Convert [...]
Add Digits of the Number Using Single Statement : [crayon-60940c7146cca129599888/] Output : [crayon-60940c7146cd1157051521/] How ? [crayon-60940c7146cd4256123203/] In 'For Loop' Condition is first tested and then body is executed. Carefully Look at Semicolon at the end of 'For Loop' , which tells us two Things - For Loop is Bodyless. Only Condition and Increment Statements will be executed.
Way 1 : Using Recursive Function [crayon-60940c714706a248149139/] Way 2 : Using While Loop [crayon-60940c7147071299486645/] Way 3 : Using While Loop [crayon-60940c7147075369875741/] Way 4 : Using For Loop [crayon-60940c7147078800189513/] Way 5 : Using Subtraction [crayon-60940c714707b464769349/] Note : This Example have Arithmetic Operator [-] but this example is for "Adding two numbers without using + Operator "
Make Your Own Header File ? Step1 : Type this Code [crayon-60940c71474c5539199892/] In this Code write only function definition as you write in General C Program Step 2 : Save Code Save Above Code with [.h ] Extension . Let name of our header file be myhead [ myhead.h ] Compile Code if required. Step 3 : Write Main Program [crayon-60940c71474cc171512200/] Include Our New Header File . Instead of writing < myhead.h> use this terminology "myhead.h" All the Functions defined in the myhead.h header file are now ready for use . Directly [...]
Run C Program Without Main Function Conceptually C Program is meaningless without main Function . Every Program Must have Main Function. Main Function : It is Entry Point of Every C Program. All Predefined and User-defined Functions are called directly or indirectly through the main. So C Program Must have Main Function. But I have decided not to write main and want to run C Program , How ? We have 3 approaches of Writing C Program without using main(). Way 1 : Using #define Preprocessor Directive [crayon-60940c7147876284666485/] What [...]
Method 1 : Using Array If more than two variables of same type is to be returned then we can use array .Store each and every value to be returned in an array and return base address of that array.Method 2 : Using Pointer and One Return StatementPointer Variable can updated directly using Value at ['*'] Operator.Usually Function can return single value.If we need to return more than two variables then update 1 variable directly using pointer and return [...]
Power of Interrupts : Interrupts are messages to the Pentium chip to halt it current activity, and perform our requested job. We can almost do anything using interrupts without using functions. Note below example - we haven't used printf() still we are able to print message on screen. Live Program : [crayon-60940c7148031222941831/] Output: [crayon-60940c7148038157269924/] Explanation of Program : [crayon-60940c714803b409556823/] dos.h header file contain geninterrupt() function which is used to create interrupt. geninterrupt(0x21) is used to generate 0x21 interrupt. Note that the sentence is ended with a ‘$’ which is a terminating [...]
Print 1-10 numbers without using Conditional Loop i.e without using for Loop while Loop do-while Loop This can be achieved in 3 ways : Using Printf Statement 10 Times. Using Recursive Function Using goto Statement. Recursive Main Function Way 1 : Printf Statement 10 times [crayon-60940c7148426459488348/] Use 10 Times Printf Statement . Way 2 : Recursive Function [crayon-60940c714842d095262765/] Recursive function : Calling Itself . printNumber function calls itself so it is called Recursive function . Way 3 : Using Goto Statement [crayon-60940c7148431878881692/] Way 4 : Using Recursive Main [crayon-60940c7148433026202424/] Static variable inside a function means "once the variable [...]