
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

341 Views
ProblemHow to display the current date and time in ISO standard format using C Programming language?SolutionThe current date and time of the input will be taken and we are trying to print the system time and date in ISO format.For example, Monday, Dec 15, 2020 10.50p.The built-in functions that we used in this program are −Time() − returns current time.Strftime() − converts the time to string form, this function include in time.h.Example Live Demo#include #include int main(){ time_t current = time(NULL); char datetime[20]; strftime(datetime, sizeof(datetime), "%a, %d%b%y %H:%M", localtime(¤t)); puts(datetime); return 0; }OutputThu, 31 Dec 20 ... Read More

547 Views
The atexit() is a function that allows the user to register a function that has to be called based on program termination.It is a predefined function that is included in stdlib header files.Example 1 Live Demo#include #include void welcome(void){ printf("Welcome to New, "); } void world(void){ printf("World"); } int main(){ //test atexit ,call user defined function atexit(world); atexit(welcome); return 0; }OutputWelcome to New, WorldExample 2 Live Demo#include #include void first(void){ printf("This is a beautiful, "); } void second(void){ printf("Wonderful life"); } int main(){ //test atexit ,call user defined function atexit(second); atexit(first); ... Read More

887 Views
ProblemWrite a C program to calculate the deposited amount incremented after some years with interestSolutionThe formula for calculating interest is −M=((r/100) * t); A=P*exp(M);Where r= rate of interest t=no. of years P=amount to be deposited M=temporary variable A= Final amount after interestAlgorithmSTART Step 1: declare double variables Step 2: read amount to be deposited Step 3: read rate of interest Step 4: read years you want to deposit Step 5: Calculate final amount with interest I. ... Read More

23K+ Views
ProblemWrite a C program for storing the details of 5 students into a file and print the same using fread() and fwrite()SolutionThe fread() function reads the entire record at a time.Syntaxfread( & structure variable, size of (structure variable), no of records, file pointer);Examplestruct emp{ int eno; char ename [30]; float sal; } e; FILE *fp; fread (&e, sizeof (e), 1, fp);The fwrite() function writes an entire record at a time.Syntaxfwrite( & structure variable , size of structure variable, no of records, file pointer);Examplestruct emp{ int eno: char ename [30]; float sal; } e; FILE ... Read More

827 Views
ProblemWrite a C program to concatenate n characters from source string to destination string using strncat library functionSolutionThe strcat functionThis function is used for combining or concatenating two strings.The length of the destination string must be greater than the source string.The resultant concatenated string will be in the source string.Syntaxstrcat (Destination String, Source string);Example 1#include main(){ char a[50] = "Hello"; char b[20] = "Good Morning"; clrscr ( ); strcat (a, b); printf("concatenated string = %s", a); getch ( ); }OutputConcatenated string = Hello Good MorningThe strncat functionThis function is used for combining or ... Read More

3K+ Views
Strncmp is a predefined library function present in string.h file, it used to compare two strings and display which string is greater.The strcmp fucntion (String comparison)This function compares 2 strings. It returns the ASCII difference of the first two non– matching characters in both the strings.Syntaxint strcmp (string1, string2);If the difference is equal to zero, then string1 = string2.If the difference is positive, then string1> string2.If the difference is negative, then string1 0) { printf("%s is greater than %s", string1, string2); } else { printf("%s is less than %s", string1, string2); } ... Read More

17K+ Views
ProblemHow to read a series of items that are present in a file and display the data in columns or tabular form using C ProgrammingSolutionCreate a file in write mode and write some series of information in the file and close it again open and display the series of data in columns on the console.Write mode of opening the fileFILE *fp; fp =fopen ("sample.txt", "w");If the file does not exist, then a new file will be created.If the file exists, then old content gets erased & current content will be stored.Read mode of opening the file FILE *fp fp =fopen ... Read More

307 Views
Open a file in reading mode. If the file exists, then write a code to count the number of lines in a file. If the file does not exist, it displays an error that the file is not there.The file is a collection of records (or) It is a place on the hard disk where data is stored permanently.Following are the operations performed on files −Naming the fileOpening the fileReading from the fileWriting into the fileClosing the fileSyntaxFollowing is the syntax for opening and naming a file −1) FILE *File pointer; Eg : FILE * fptr; 2) File pointer ... Read More

1K+ Views
A pointer is a variable that stores the address of another variable.Features of PointersPointer saves the memory space.The execution time of a pointer is faster because of direct access to memory location.With the help of pointers, the memory is accessed efficiently, i.e., memory is allocated and deallocated dynamically.Pointers are used with data structures.Declaring a pointerint *p;It means ‘p’ is a pointer variable that holds the address of another integer variable.Initialization of a pointerAddress operator (&) is used to initialize a pointer variable.For example, int qty = 175; int *p; p= &qty;Accessing a variable through its pointerTo access the value of ... Read More

969 Views
ProblemWrite a C program to define the structure and display the size and offsets of member variablesStructure − It is a collection of different datatype variables, grouped together under a single name.General form of structure declarationdatatype member1; struct tagname{ datatype member2; datatype member n; };Here, struct - keywordtagname - specifies name of structuremember1, member2 - specifies the data items that make up structure.Examplestruct book{ int pages; char author [30]; float price; };Structure variablesThere are three ways of declaring structure variables −Method 1struct book{ int pages; char author[30]; float price; }b;Method 2struct{ ... Read More