#include <stdio.h>#include <conio.h>#include <stdlib.h>#include <ctype.h>void main(){ int i,j=0,l=0,p[50],pos,n; char str[50],substr[50],dir[6],dir1[4]=”left”,k; clrscr(); printf(“nnEnter a string:”); scanf(“%s”,str); printf(“nEnter position, no. of character direction of sub string:”); scanf(“%d%d%s”,&pos,&n,dir); for(i=0;str[i]!=”;i++) l++; for(i=0;dir[i]!=”;i++) { if(toupper(dir[i])==toupper(dir1[i])) k=’l’; else { k=’r’; break; } } if(toupper(k)==’L’) { if(pos==0||(pos-n)<0) …
// program to test palindrome number#include <stdio.h>#include <conio.h>#include <math.h>void main(){ int n,dig,rev=0,temp; clrscr(); printf(“Enter a number:”); scanf(“%d”,&n); temp=n; while(temp!=0) { dig=temp%10; rev=rev*10+dig; temp=temp/10; } printf(“nnThe reverse of %d is %d”,n,rev); if(rev==n) { printf(“nn%d is palindrome”,n); } else { printf(“nn%d is …
#include <conio.h>#include <stdio.h>void main(){ int m, n, p, q, c, d, k, sum = 0; int first[10][10], second[10][10], multiply[10][10]; clrscr(); printf(“Enter the number of rows and columns of first matrixn”); scanf(“%d%d”, &m, &n); printf(“Enter the elements of first matrixn”); for …
#include <stdio.h>#include <conio.h>#include <stdlib.h>#include <ctype.h>#include <string.h>#include <dos.h>void main_menu();void create_marksheet();void delete_marksheet();void view_marksheet();void switch_case(int);typedef struct{ long roll; int marks[6], total,i; float p; char fname[20],lname[10], result[6];}student;FILE *fp, *tfp;student s;char cont;int i;void main(){ clrscr(); main_menu();}void main_menu(){ int ch; textcolor(9); for(i=0;i<42;i++) { gotoxy(25+i,5); printf(“%c”,254); } …
#include<stdio.h>#include <conio.h>int sum(int, int);void diff();int prod();void div(int, int);void main(){ int a,b,res; clrscr(); printf(“Enter 2 numbers:”); scanf(“%d%d”, &a,&b); res=sum(a,b); printf(“nSum is %dn”,res); diff(); res=prod(); printf(“nThe product is %d”,res); div(a,b); getch();}int sum(int x, int y){ return(x+y);}void diff(){ int a,b; printf(“nnEnter 2 numbers:”); …
#include <stdio.h>#include <conio.h>void main(){ int n, first = 0, second = 1, next, c; clrscr(); printf(“Enter the number of termsn”); scanf(“%d”,&n); printf(“First %d terms of Fibonacci series are :-n”,n); for ( c = 0 ; c < n ; c++ …
#include <stdio.h>#include <conio.h>int fact(int);void main(){ int n,f; clrscr(); printf(“Enter a number:”); scanf(“%d”,&n); f=fact(n); printf(“Factorial (%d)=%d.”,n,f); getch();}int fact(int x){ if(x==0||x==1) return(1); else return(x*fact(x-1));}
#include <stdio.h>#include <conio.h>main(){ int i, j; clrscr(); for(i=0;i<8;i++) { gotoxy(30,10+i); for(j=0;j<8;j++) { if(i%2==0 && j%2==0 || i%2!=0 && j%2!=0) { printf(“%c%c”, 176,176); } else if(i%2==0 &&j%2!=0 || i%2!=0 && j%2==0) { printf(“%c%c”, 219,219); } } printf(“n”); } getch();}
#include <conio.h>#include <stdio.h>void main(){ int i,j,tmp, first, last, middle, n, val, num[100]; clrscr(); printf(“Enter number of elementsn”); scanf(“%d”,&n); printf(“Enter %d integersn”, n); for ( i = 0 ; i < n ; i++ ) scanf(“%d”,&num[i]); for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(num[i]>num[j]) …
#include <stdio.h>#include <conio.h>#include <stdlib.h>void sort_asc(int [],int);void sort_dsc(int [],int);void search_lin(int [],int);void search_bin(int [],int);void insert(int [],int);void delet(int [],int);void merge(int [], int);void display(int [],int);void menu(int [], int);void main(){ int n, a[50],b[50],c[100],i; clrscr(); printf(“Enter no. of values:”); scanf(“%d”,&n); printf(“Enter %d values:”,n); for(i=0;i<n;i++) { scanf(“%d”,&a[i]); …
