C Programming : Programs

Calender Program in C Programming Language : Display Day of the month

Calender Program in C Programming Language : Display Day of the month Calender Program in C Programming Language : Program will accept Year,Month and Date from the user and will display the day of the month. #include<stdio.h> #include<conio.h> #include<math.h> int isdatevalid(int month, int day, int year) { if (day <= 0) return 0 ; switch( [...]

C Program to Check whether Matrix is Magic Square or Not ?

C Program to Check whether entered matrix is magic square or not ? What is Magic Square : A magic square is a simple mathematical game developed during the 1500. Square is divided into equal number of rows and columns. Start filling each square with the number from 1 to num ( where num = [...]

C Program to perform Stack Operations Using Pointer !

Write a C program using pointers to implement a stack with all the operations. Program to implement stack with its operations using pointers #include<stdio.h> #include<conio.h> #include<stdlib.h> #define MAX 50 int size; /* Defining the stack structure */ struct stack { int AR[MAX]; int top; }; /* Initializing the stack(i.e., top=-1) */ void init_stk(struct stack *st) [...]

C program to copy the contents of one file into another using fputc

Program to copy the contents of one file into another using fgetc and fputc function #include<stdio.h> #include<process.h> void main() { FILE *fp1,*fp2; char a; clrscr(); fp1=fopen(“test.txt”,”r”); if(fp1==NULL) { puts(“cannot open this file”); exit(1); } fp2=fopen(“test1.txt”,”w”); if(fp2==NULL) { puts(“Not able to open this file”); fclose(fp1); exit(1); } do { a=fgetc(fp1); fputc(a,fp2); }while(a!=EOF); fcloseall(); getch(); } Output [...]

C Program to read last n characters from the file !

Write a C program to read last n chatacters of the file using appropriate file function Problem Statement : Write a C Program to read last n characters from the file . Open a file in read mode. Accept value of n . #include<stdio.h> void main() { FILE *fp; char a; int n; long len; [...]

C program to convert the file contents in Upper-case & Write Contents in a output file

C program to convert the file contents in Upper-case & Write Contents in a output file Write a program to read a text file and convert the file contents in capital (Upper-case) and write the contents in a output file. Program to copy the contents of one file into another by changing case. #include<stdio.h> #include<process.h> void [...]

C Program to compute sum of the array elements using pointers !

Write a ‘C’ Program to compute the sum of all elements stored in an array using pointers C Program to compute sum of the array elements using pointers Program : #include<stdio.h> #include<conio.h> void main() { int a[10]; int i,sum=0; int *ptr; printf(“Enter 10 elements:\n”); for(i=0;i<10;i++) scanf(“%d”,&a[i]); ptr = a; /* a=&a[0] */ for(i=0;i<10;i++) { sum [...]

C Program to read, print name and other details of 50 students using Structure?

C Program to read, print name and other details of 50 students ? Problem Statement : The annual examination is conducted for 50 students for three subjects. Write a program to read the data and determine the following: (a) Total marks obtained by each student. (b) The highest marks in each subject and the Roll [...]

C Program to count number of words,digits,vowels using pointers in C Programming

Write a program to count the number of words, lines and characters in a text Program finding number of words, blank spaces, special symbols, digits, vowels using pointers Count Number of Words using Pointer #include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<conio.h> /*low implies that position of pointer is within a word*/ #define low 1 /*high implies that position [...]