C Programming Project

C Programming Project – A sample Mathematics Project

You can read though the code or download below. The library files for the Graphics such as “EGAVGA.BGI“, “C0C.OBJ” etc can be found inside the Zip Folder. Further, in the code itself various comments are added for simple understanding of the program.

Note: The Compiler used for this project was “TURBO C++“. So, it is suggested to use the same compiler while debugging and running the program.

Screenshots of the Sample Mathematics Project written in C

Flow Chart of the Sample Mathematics Project written in C

Flowchart C Programming Project

/*Program written by Ruhul Amin Khan to understand simply the usage of ¬†functions, pointers, linked lists, structures in ‘C’ and some coding to solve some mathematical problems using ‘C’ */

#include<graphics.h>

#include<stdio.h>

#include<conio.h>

#include<math.h>

#include<stdlib.h>

void name(void);       //Function Declarations

char caselist(void);

int add(int);

int sub(void);

int mul(int);

void prime(void);

void mat(void);

void cal(void);

void matmult(void);

void si(void);

void trans(void);

void ci(void);

void tri(void);

void cir(void);

void circum(void);

void cylin(void);

void mtable(void);

void manipulat(void);

void arms(void);

void fibbo(void);

void arraysort(void);

void arrayinsert(void);

void arraydelete(void);

void dtob(void);

void btod(void);

void length(void);

void vowel(void);

void join (void);

void rdisplay(void);

void pelin(void);

void utol(void);

void chart(void);

void linkedlist(void);

void bit(void);

void stack(void);

void queue(void);

struct node *creat(void);

struct node *bjoin(struct node*);

struct nod *crea(void);

void Ejoin(struct nod *);

void disp(struct nod *);

void display(struct node*);

struct node{

                                                int info;

                                                struct node* next;

                                                };

struct nod{

int inf;

struct nod *Next;

};

void main(void)     //Main Function

{

            int menu,gd = DETECT, gm ;

            char t,str[40],r,r1,list;

            initgraph ( &gd, &gm, “c:\\tc\\bgi” ) ;

            clrscr();

            setcolor (RED) ;

            outtextxy(190,30,”*****SCHOOL NAME*****”);

            setcolor(BLUE);

            outtextxy(290,50,”By”);

            outtextxy(220,60,”***RUHUL AMIN KHAN***”);

            setcolor(YELLOW);

            name();                                   //Function calling 1

            printf(“\n\n”);

            printf(”                  Do you want to start the application ?\n”);

            printf(”                    <<<Press Y/y for ‘Yes’ N/n for ‘No’>>>\n”);

            t=getch();

            if(t==’y’||t==’Y’)

            {

            list=caselist();  //Function calling 2

            switch (list)

            {

                        case ‘a’:

                        case ‘A’:

                                    clrscr();

                                    cal();      //Function calling 3

                                    printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     clrscr();

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                                    break;

                        case ‘b’:

                        case ‘B’:

                                    printf(“\n”);

                                    linkedlist();    // Function calling 6.11

                                    printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     linkedlist();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                                    break;

                        case ‘c’:

                        case ‘C’:

                                    bit();

                                    printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     bit();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                                    break;

                        case ‘d’:

                        case ‘D’:

                                    manipulat();  //Function calling 8

                                    printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     manipulat();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                                    break;

                        default:

                                     printf(”           <<<|| Do U want to start again Press Y or N||>>>\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                    else

                                    exit(1);

                                    break;

            }

}

else

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

            getch();

            closegraph( ) ;

            restorecrtmode( ) ;

}

void name()                             //Function definition 1

{

            int gd = DETECT,gm ;

            char  str[40] ;

            initgraph ( &gd,&gm, “c:\\tc\\bgi” ) ;

            setcolor(GREEN);

            outtextxy(260,70,”<<<<<<*>>>>>>”);

            outtextxy(160,80,”<<<<MATHEMATICAL PROBLEM SOLUTIONS>>>>”);

            outtextxy(180,90,”<<<USING COMPUTER PROGRAMMING>>>”);

            outtextxy(218,110,”COMPILER : TURBO C++”);

            outtextxy(185,130,”<<N.B.View the source code>>”);

            outtextxy(90,150,”default drive C:\\Program File\\ Doeacc\\ SourceCode.txt”);

            outtextxy(200,390,”Press any key to start….”);

            settextjustify(CENTER_TEXT, CENTER_TEXT);

            settextstyle(GOTHIC_FONT, HORIZ_DIR,4);

            setcolor(RED);

            outtextxy(getmaxx()/2.1,getmaxy()/2.4, “By”);

            setcolor(BLUE);

            outtextxy(getmaxx()/2,getmaxy()/2, “Mr.Ruhul Amin Khan”);

            setcolor(RED);

            outtextxy(getmaxx()/2,getmaxy()/1.7,”Under the guidance of”);

            setcolor(BLUE);

            outtextxy(getmaxx()/2,getmaxy()/1.5,”Miss.Jhuma Singh”);

            getch( ) ;

            closegraph( ) ;

            restorecrtmode( ) ;

}

char caselist()  //Function definition 2

{

            char v;

            clrscr();

            printf(”                 *************MAIN MENU*************\n”);

             printf(”              \n”);

             printf(”                               \n”);

            printf(”          \t \A. Calculation           \n”);

            printf(”          B. Linked Lists in C\n”);

            printf(”          C. Operation on bits in C\n”);

            printf(”          \t D. Manipulation on character & string in ‘c’\n”);

            printf(”                    Press 1 to exit”);

            printf(“\n”);

            printf(”          Enter your choice? <E.g. press A for calculation>\n “);

            scanf(“%c”,&v);

            printf(”                     Ok ! U have pressed %c\n\n”,v);

            if(v==’1′)

            {

             exit(1);

             }

            return v;

}

void cal()                     //Function Definition 3

{

            int k,l,m,i,j,n,r,p,q,t,u,x,r1;

            clrscr();

            printf(”            ***************CALCULATION***************\n”);

            printf(”                    *******  SUB MENU*******\n”);

            printf(”               Press \n”);

            printf(”               1. For Addition\n”);

            printf(”               2. For Subtraction\n”);

            printf(”               3. For Multiplication\n”);

            printf(”               4. For Division\n”);

            printf(”               5. For Simple Interest\n”);

            printf(”               6. For Compound Interest\n”);

            printf(”               7. For Area of a Triange\n”);

            printf(”               8. For Area of a Circle\n”);

            printf(”               9. For Circumferance of a circle\n”);

            printf(”              10. For Surface Area of a cylinder\n”);

            printf(”              11. For Multipliction table\n”);

            printf(”              12. Check a digit Armstrong or not\n”);

            printf(”              13. Displaying Fibbonaccy series to 100\n”);

            printf(”              14. Sorting Array elements\n”);

            printf(”              15. Matrix multiplication\n”);

            printf(”              16. Check for number prime or not\n”);

            printf(”              17. Transpose of a matrix\n”);

            printf(”                  Press 0 to Main Window\n “);

            printf(”                  Press 00 to exit\n”);

            printf(”            Enter your choice..[E.g. Say 5 for Simple Interest]\n”);

            scanf(“%d”,&k);

            if(k==0)

            {

            name();

            }

            if(k==00)

            {

             exit(1);

             }

            printf(”            you have selected %d\n”,k);

            switch (k)

            {

            case 1:

                        printf(“\n”);

                        clrscr();

                        printf(”                     Enter no of operands for addition\n”);

                        scanf(“%d”,&l);

                        printf(”                     Enter operands one by one\n”);

                        for(i=0;i<l;i++)

                        {

                                    scanf(“%d”,&j);

                                    m=add(j);   //Function calling by value 3.1

                        }

                        printf(”                     The addition result is %d”,m);

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 2:

                        clrscr();

                        printf(“\n”);

                        n=sub();  //Function calling 3.2

                        printf(”                     The subtraction result is %d”,n);

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 3:

                        clrscr();

                        printf(“\n”);

                        printf(”                     Enter no of operands for multiplication\n”);

                        scanf(“%d”,&p);

                        printf(”                     Enter operands one by one\n”);

                        for(i=0;i<p;i++)

                        {

                                    scanf(“%d”,&q);

                                    r=mul(q);    //Calling Function by value 3.3

                        }

                        printf(”                     The multiplication result is %d”,r);

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 4:

                        clrscr();

                        printf(“\n”);

                        printf(”                     Enter two values for division\n”);

                        scanf(“%d%d”,&t,&u);

                        x=t/u;

                        printf(”                     The division result is %d”,x);

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 5:

                        si();          //Calling Function 3.4

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 6:

                        ci();          //Calling Function 3.5

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 7:

                        tri();         //Calling Function 3.6

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 8:

                        cir();         //Calling Function 3.7

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 9:

                        circum();      //Calling Function 3.8

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 10:

                        cylin();       //Calling Function 3.9

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 11:

                        mtable();      //Calling Function 3.10

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 12:

                        arms();        //Calling Function 3.11

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 13:

                        fibbo();       //Calling Function 3.12

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 14:

                        arraysort();  //Calling Function 3.13

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 16:

                        prime();

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 17:

                        trans();

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            case 15:

                        matmult();

                         printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     cal();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

                        break;

            default:

                        printf(”                     Wrong choice!”);

                        break;

            }

}

void manipulat() //Function Definition 8

{

int a;

char r,r1;

clrscr();

printf(”                           <<<SUB MENU>>>\n\n”);

printf(”            1. Count length of a string [Without library function strlen();]\n”);

printf(”            2. Count number of vowels from a string\n”);

printf(”            3. English Alphabets and their ASCII values\n”);

printf(”            4. Join or Concatenate two strings\n”);

printf(”            5. Reverse display of a string\n”);

printf(”            6. Check whether a word is pelindrome or not\n”);

printf(”               Press 0 to Main Window\n”);

printf(”               Press 00 to exit\n\n”);

printf(”            Enter your choice…[E.g. press 1 to know the length of a string\n”);

scanf(“%d”,&a);

if(a==0)

{

 name();

 }

if(a==00)

{

 exit(1);

 }

switch (a)

  {

            case 1:

              length();    //Calling Function 6.1

               printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     manipulat();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

              break;

            case 2:

              vowel();     //Calling Function 6.2

               printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     manipulat();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

              break;

            case 4:

              join();      //Calling Function 6.4

               printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     manipulat();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

              break;

            case 5:

              rdisplay();  //Calling Function 6.5

               printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     manipulat();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

              break;

            case 6:

              pelin();     //Calling Function 6.6

               printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     manipulat();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

              break;

            case 999:

              utol();      //Calling Function 6.7

               printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     manipulat();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

              break;

            case 3:

              chart();      //Calling Function 6.8

              printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/N|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     manipulat();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/N\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     exit(1);

                                     }

              break;

            default:

              printf(”                         Oops! Wrong choice…”);

              break;

  }

}

void si()      //Function Definition 3.4

{

 float p,r,si;

 int n;

 clrscr();

 printf(”                       <<<Simple Interest>>>\n”);

 printf(“Enter Principal\n”);

 scanf(“%f”,&p);

 printf(“Enter Year\n”);

 scanf(“%d”,&n);

 printf(“Enter Rate of Interest\n”);

 scanf(“%f”,&r);

 si=(p*n*r)/100;

 clrscr();

 printf(”                               <<<Simple Interest>>>\n\n”);

 printf(”                       Principal            = %.2f Rs/-\n”,p);

 printf(”                       Year                 = %  d Year\n”,n);

 printf(”                       Rate of Interest     = %.2f %\n\n”,r);

 printf(”                       The Simple Interest  = %.2f Rs/-\n”,si);

}

void ci()     //Function Definition 3.5

{

 float p,r,ci=0,pows=0,a,b;

 int  n;

 clrscr();

 printf(”                      <<<COMPOUND INTEREST>>>\n\n”);

 printf(“Enter principal\n”);

 scanf(“%f”,&p);

 printf(“Enter rate of interest\n”);

 scanf(“%f”,&r);

 printf(“Enter Year\n”);

 scanf(“%d”,&n);

 b=1+r/100;

 pows=pow(b,n);

 a=p*pows;

 ci=a-p;

 clrscr();

 printf(”                      <<<COMPOUND INTEREST>>>\n\n”);

 printf(“Principal                = %.2f Rs/-\n”,p);

 printf(“Rate of Interest         = %.2f %\n”,r);

 printf(“Year                     = %d Year\n”,n);

 printf(“The Compound Interest is = %.2f Rs/-\n”,ci);

}

void tri()   //Function Definition 3.6

{

 float a,b,c;

 clrscr();

 printf(”                  <<<Area of a Triangle>>>\n”);

 printf(“Enter Base\n”);

 scanf(“%f”,&a);

 printf(“Enter Height\n”);

 scanf(“%f”,&b);

 c=0.5*a*b;

 clrscr();

 printf(”                  <<<Area of a Triangle>>>\n\n\n”);

 printf(”             Base   = %.2f\n”,a);

 printf(”             Height = %.2f\n\n”,b);

 printf(”             The Area of the Triangle is = %.2f\n”,c);

}

void cir()   //Function Definition 3.7

{

 float a,c=0;

 clrscr();

 printf(“Enter Radious \n”);

 scanf(“%f”,&a);

 c=3.14*a*a;

 clrscr();

 printf(”                         <<<Area of a Circle>>>\n”);

 printf(”   Radious = %.2f\n”,a);

 printf(”   The Area of a Circle = %.2f\n\n”,c);

}

void circum() //Function Definition 3.8

{

 float a,b;

 clrscr();

 printf(”                      <<<Circumference of a Circle>>>\n\n\n”);

 printf(“Enter Radious\n “);

 scanf(“%f”,&a);

 b=2*3.14*a;

 clrscr();

 printf(”                      <<<Circumference of a Circle>>>\n\n\n”);

 printf(”       Enterd Raious     =  %.2f\n”,a);

 printf(”       The Circumference =  %.2f\n”,b);

}

void cylin()  //Function Definition 3.9

{

 float r,h,a;

 clrscr();

 printf(”                         <<<Surface area of a Cylinder>>>\n\n”);

 printf(”   Enter Radious of the Cylinder\n”);

 scanf(“%f”,&r);

 printf(”   Enter Height of the Cylinder\n”);

 scanf(“%f”,&h);

 a=2*3.14*r*(h+r);

 clrscr();

 printf(“\n”);

 printf(”                        <<<Surface area of a Cylinder>>>\n\n”);

 printf(”   Enterd Radious        = %.2f\n”,r);

 printf(”   Enterd Height         = %.2f\n\n”,h);

 printf(”   The resultant area is =%.2f\n”,a);

}

int sub()           //Function Definition 3.2

{

            int i,j,k;

            printf(”                        Enter two number for subtraction…\n”);

            scanf(“%d%d”,&i,&j);

            k=i-j;

            return k;

}

int add(int n)  //Function Definition 3.1

{

            static int m=0;

            m=m+n;

            return m;

}

int mul(int a)  //Function Definition 3.3

{

            static int b=1;

            b=b*a;

            return b;

}

void prime()    //Function Definition 4

{

            int i=0,j=0,no;

            clrscr();

            printf(”                      Enter a number to check for prime or not\n”);

            scanf(“%d”,&no);

            i=2;

            if(i<no)

            {

                        for(i=2;i<no-1;i++)

                        {

                                    if(no%i==0)

                                    {

                                                printf(”                     No is not prime\n”);

                                                j=1;

                                                break;

                                    }

                        }

                        if(j==0)

                        {

                                    printf(”                         No is prime\n”);

                        }

            }

            else

                                    printf(”                         No is prime\n”);

}

void mat()  //Function Definition 5

{

            int a[2][2],b[2][2],c[2][2],i,j;

            clrscr();

            printf(”       \t\t********* Matrix Addition*********\n”);

            printf(“\n”);

            printf(“\tInput values in the 1st two dimensional matrix\n”);

            for(i=0;i<2;i++)

            {

                        for(j=0;j<2;j++)

                                    scanf(“%d”,&a[i][j]);

            }

            printf(“\tInput values in the 2nd two dimensional matrix\n”);

            for(i=0;i<2;i++)

            {

                        for(j=0;j<2;j++)

                                    scanf(“%d”,&b[i][j]);

            }

            for(i=0;i<2;i++)

            {

                        for(j=0;j<2;j++)

                                    c[i][j]=a[i][j]+b[i][j];

            }

            printf(“\tThe Addition result of 2D Matrix is as follows->\n”);

            for(i=0;i<2;i++)

            {

                        for(j=0;j<2;j++)

                        {

                                    printf(“\t\t\t%d”,c[i][j]);

                                    }

                                    printf(“\n”);

            }

}

void trans()   //Function Definition 6

{

            int a[3][3],b[3][3],i,j;

            clrscr();

            printf(”               <<<Transpose of Matrix>>>\n\n”);

            printf(“Enter values in the matrix to transpose…\n”);

            for(i=0;i<3;i++)

            {

             for(j=0;j<3;j++)

             scanf(“%d”,&a[i][j]);

             }

             for(i=0;i<3;i++)

             {

              for(j=0;j<3;j++)

              b[j][i]=a[i][j];

              }

              clrscr();

              printf(”               <<<Transpose of Matrix>>>\n”);

              printf(“\n”);

              printf(“The entered values in the 3D matrix are….\n”);

              for(i=0;i<3;i++)

              {

                        for(j=0;j<3;j++)

                        {

                        printf(“\t%d”,a[i][j]);

                        }

                        printf(“\n”);

              }

              printf(“After transpose the matrix is…\n”);

              for(i=0;i<3;i++)

                        {

                          for(j=0;j<3;j++)

                          {

                                    printf(“\t%d”,b[i][j]);

                                    }

                                    printf(“\n”);

                        }

             }

void matmult()    //Function calling 7

{

            int a[2][2],b[2][2],c[2][2],i,j,k;

            clrscr();

            printf(”                     <<<Matrix Multiplication>>>\n\n”);

            printf(“\nInput values in the first two dimensional matrix\n”);

            for(i=0;i<2;i++)

             {

                        for(j=0;j<2;j++)

                        scanf(“%d”,&a[i][j]);

                        }

            printf(“Input values in the second two dimensional matrix\n”);

            for(i=0;i<2;i++)

             {

              for(j=0;j<2;j++)

              scanf(“%d”,&b[i][j]);

              }

            for(i=0;i<2;i++)

             {

              for(j=0;j<2;j++)

              {

                        c[i][j]=0;

                        for(k=0;k<2;k++)

                        c[i][j]=c[i][j]+a[i][k]*b[k][j];

                        }

             }

             clrscr();

            printf(”                      *****Matrix multiplicatin*****\n\n”);

            printf(”                      The elements of first matrix is->\n”);

             for(i=0;i<2;i++)

             {

              for(j=0;j<2;j++)

              {

                        printf(“\t\t\t%d”,a[i][j]);

              }

              printf(“\n”);

             }

             printf(”                    The elements of second matrix is->\n”);

             for(i=0;i<2;i++)

             {

              for(j=0;j<2;j++)

              {

                        printf(“\t\t\t%d”,b[i][j]);

              }

              printf(“\n”);

             }

             printf(“\n”);

            printf(”                 After multiplication the resultant matrix is->\n”);

            for(i=0;i<2;i++)

             {

                        for(j=0;j<2;j++)

                        {

                          printf(“\t\t\t%d”,c[i][j]);

                        }

                        printf(“\n”);

             }

            }

void mtable() //Function Definition 3.10

{

 int a=0,b=0,c=0;

 char ans;

 clrscr();

 printf(”                         <<<MULTIPLICATION TABLE>>>\n\n”);

 printf(”           Enter a digit to get the multiplication table\n”);

 scanf(“%d”,&a);

 clrscr();

 printf(”                         <<<MULTIPLICATION TABLE>>>\n\n”);

 printf(”           The required multiplication table is ->\n\n”);

 for(b=1;b<11;b++)

 {

  c=a*b;

  printf(”        \t\t\t%d  X %3d =  %d”,a,b,c);

  printf(“\n”);

 }

}

void arms()    //Function Definition 3.11

{

 int i,no,d=0,c;

 clrscr();

 printf(”                       <<<Armstrong Digit>>>\n\n\n”);

 printf(”        N.B. Armstrong digit is the addition of cube of that digit\n”);

 printf(”                     E.g.  153= (1x1x1)+(5x5x5)+(3x3x3)\n\n”);

 printf(”        Enter a digit\n”);

 scanf (“%d”,&no);

 i=no;

 while(i>0)

 {

  c=i%10;

  i=i/10;

  d=d+(c*c*c);

}

if(no==d)

{

 printf(”       No is Armstrong!\n”);

 }

 else

 printf(”       No is not Armstrong\n”);

}

void fibbo()     //Function Definition 3.12

{

 int a=0,b=1,c,i;

 clrscr();

 printf(“\n\n”);

 printf(”                        Fibbonaccy Series is ->\n”);

 printf(”         [The addition of first two digit is the third digit]\n\n”);

 printf(” %d %d “, a,b);

 for(i=0;i<20;i++)

 {

  c=a+b;

  a=b;

  b=c;

  printf(” %d”,c);

}

printf(“\n”);

}

void arraysort()  //Function Definition 3.13

{

  int a[5],i,j,t;

  clrscr();

  printf(”            <<<Sorting Array elements ascending & descending order>>>\n\n”);

  printf(“Input 5 digits in the array randomly->\n”);

  for(i=0;i<5;i++)

  {

            scanf(“%d”,&a[i]);

            }

            for(i=0;i<5;i++)

            {

             for(j=i+1;j<=5;j++)

             {

              if(a[i]>a[j])

              {

                        t=a[i];

                        a[i]=a[j];

                        a[j]=t;

                        }

              }

             }

            printf(“After sorting in ascending order the array elements are->\n”);

            for(i=0;i<5;i++)

            {

             printf(” %d”,a[i]);

             }

             for(i=0;i<5;i++)

             {

              for(j=i+1;j<5;j++)

                        {

                         if(a[i]<a[j])

                         {

                          t=a[i];

                          a[i]=a[j];

                          a[j]=t;

                          }

                         }

                        }

             printf(“\n\n”);

             printf(“After sorting in descending order the array elements are->\n”);

             for(i=0;i<5;i++)

             {

              printf(” %d”,a[i]);

             }

             printf(“\n”);

}

void arrayinsert()  //Function Definition 3.14

{

clrscr();

printf(“array insert is under construction\n”);

}

void arraydelete()  //Function Definition 3.15

{

 clrscr();

 printf(“Deleting an element from an array is under construction\n”);

}

void dtob()        //Function Definition 3.16

{

 int no, i,rem=0,j;

 char a[30]=”00000000000000000000000000000\0″;

 clrscr();

 printf(“\n”);

 printf(”               **********Deciamal to Binary*********\n\n”);

 printf(”       Enter a decimal number to get the bianary equivalent of deciamal\n”);

 scanf(“%d”,&no);

 i=0;

 while(no>0)

 {

  rem=no%2;

  no=no/2;

  if(rem==1)

  {

  a[i]=’1′;

  }

  else

  a[i]=’0′;

  i++;

  }

  a[i+1]=’\0′;

  printf(“\n\n”);

  printf(”     The bianry number is as follows->\n\n”);

  for(j=i;j!=-1;j–)

  {

  printf (”  %c”,a[j]);

  }

}

void length()       //Function Definition 6.1

{

 char s[20],*p;

 int len=0;

 clrscr();

 printf(”           ********************Enter word**********************\n\n”);

 scanf(“%s”,s);

 p=s;

 while(*p!=’\0′)

 {

  p++;

  len++;

  }

 printf(“The length of the string is=%d\n”,len);

}

void vowel()       //Function Definition 6.2

{

 char a[20];

 int i,v=0;

 clrscr();

 printf(”         **************Enter a word to count vowel**************\n\n”);

 scanf(“%s”,a);

 i=0;

 while(a[i]!=’\0′){

 if(a[i]==’a’||a[i]==’e’||a[i]==’i’||a[i]==’o’||a[i]==’u’)

 v++;

 i++;

 }

 printf(“No of vowels=%d”,v);

}

void join()        //Function Definition 6.4

{

char a[30],b[30];

clrscr();

printf(” Enter first string\n”);

scanf(“%s”,a);

printf(“Enter second string\n”);

scanf(“%s”,b);

strcat(a,b);

printf(“After concatination the string is=%s\n”,a);

}

void rdisplay()    //Function Definition 6.5

{

char a[15];

clrscr();

printf(“Enter a string\n”);

scanf(“%s”,a);

strrev(a);

printf(“After reversing the string is=%s”,a);

}

void pelin()       //Function Definition 6.6

{

char a[15];

int check=1,i=0,len;

clrscr();

printf(”      Enter a string\n”);

scanf(“%s”,a);

len=strlen(a);

do

{

if(a[i]==a[len-1])

{

 check=0;

 }

 i++;

 len–;

 }while(i==len);

 if(check==1)

 printf(”      Word is not palindrome\n”);

 else

 printf(”      Word is Palindrome\n”);

}

void utol()        //Function Definition 6.7

{

clrscr();

printf(“Sorry, Change case is under construction\n”);

}

void chart()        //Function Definition 6.8

{

 char a=65,b=90;

 clrscr();

 printf(”                       ***********ASCII CHART***********\n\n\n”);

 printf(“Capital letters are->\n”);

 printf(“And their ASCII values->\n\n”);

 for(a=65;a<=b;a++)

 {

  printf(“%c=%d\t”,a,a);

  }

  printf(“\n\nSmall letters are->\n”);

  printf(“And their ASCII values\n\n”);

  for(a=97;a<=122;a++)

  {

            printf(“%c=%d\t”,a,a);

  }

}

/*Operation on pointers

void pointer()     //Function Definition 6.9

{

clrscr();

printf(“Operation on pointer is under construction\n”);

}                      */

/*File management in ‘C’

void file()       //Function Definition 6.10

{

 clrscr();

 printf(“File management is under construction\n”);

}                       */

/*Linked list in ‘C’*/

void linkedlist()  //Function Definition 6.11

{

int i;

char r,r1;

clrscr();

printf(”         *******************SUBMENU*******************\n\n”);

printf(”                  1. Implementation of Stack (LIFO)\n”);

printf(”           2. Implementation of Queue(FIFO)\n”);

printf(”                      Press 0 to Main Window\n”);

printf(”                      Press 00 to exit\n\n”);

printf(”                    Enter your choice…………..\n”);

scanf(“%d”,&i);

if(i==0)

{

 name();

 }

if(i==00)

{

 exit(1);

}

switch(i)

{

case 1:

            stack();

            printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/y|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     linkedlist();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/y\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     abort();

                                     }

            break;

case 2:

            queue();

            printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/y|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     linkedlist();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/y\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     abort();

                                     }

            break;

default:

            printf(“Wrong choice\n”);

            printf(“\n”);

                                    printf(”              <<<||| BACK TO PREVIOUS PRESS Y/y|||>>>\n”);

                                    r=getch();

                                    if(r==’y’||r==’Y’)

                                    {

                                     linkedlist();

                                     }

                                     else

                                     {

                                     printf(”              <<<|| BACK TO MAIN MENU PRESS Y/y\n”);

                                     r1=getch();

                                     if(r1==’y’||r1==’Y’)

                                     {

                                      main();

                                      }

                                     else

                                     abort();

                                     }

            break;

}

}

/*Operation on Bits*/

void bit()

{

 int i;

 clrscr();

 printf(”      *************** SUBMENU****************\n\n”);

 printf(”               1. Decimal to Binary\n”);

 printf(”               2. Binary to Decimal\n”);

 printf(”                  Press 0 to Main Window\n”);

 printf(”                  Press 00 to exit\n\n”);

 printf(”               Enter your choice…..\n”);

 scanf(“%d”,&i);

 if(i==0)

 {

  name();

  }

 if(i==00)

 {

  exit(1);

  }

  switch(i)

  {

  case 1:

             dtob();

             break;

  case 2:

             btod();

             break;

  default:

             printf(”          Wrong choice……\n”);

             break;

  }

  }

  void btod(void)

  {

  int p=1,rem,dec=0,no;

  clrscr();

  printf(”          *********** Binary to Decimal**********\n\n”);

  printf(”    Enter Binary Value for the operation\n”);

  scanf(“%d”,&no);

  while(no>0)

  {

   rem=no%10;

   dec=dec+(rem*p);

   p=p+p;

   no=no/10;

   }

  printf(”    The decimal value is = %d”,dec);

  }

void stack(void)

{

 struct node* start=NULL;

 char ans;

 clrscr();

 printf(”                       **********************STACK(LIFO)********************\n\n”);

 do { if(start==NULL)

                        {

                         start=creat();

                         }

                        else

                         start=bjoin(start);

                         printf(“Do u want to continue?\n”);

                         fflush(stdin);

                         scanf(“%c”,&ans);

              }while(ans==’Y’||ans==’y’);

 clrscr();

 display(start);

}

struct node* creat()

{

 struct node *np;

 np=(struct node*) malloc(sizeof(struct node));

 printf(“Enter an integer data\n”);

 scanf(“%d”,&np->info);

 np->next=NULL;

 return(np);

 }

struct node* bjoin(struct node* p)

{

 struct node* np;

 np=creat();

 np->next=p;

 p=np;

 return p;

 }

void display(struct node* p)

{

 printf(“The linked list is as follows->\n”);

 while(p->next!=NULL)

 {

  printf(” %d-> “,p->info);

  p=p->next;

  }

  }

void queue(void)

{

struct nod*st=NULL;

char Ans;

do{

if(st==NULL){

st=crea();

}

else

Ejoin(st);

printf(“Do u continune?\n”);

fflush(stdin);

scanf(“%c”,&Ans);

}while(Ans==’Y’||Ans==’y’);

clrscr();

disp(st);

}

struct nod *crea(){

struct nod *NP;

NP=(struct nod *)malloc(sizeof(struct nod));

printf(“Enter an integer data\n”);

scanf(“%d”,&NP->inf);

NP->Next=NULL;

return (NP);

}

void Ejoin(struct nod *P){

struct nod*NP;

NP=crea();

while(P->Next!=NULL)

P=P->Next;

P->Next=NP;

}

void disp(struct nod *P){

printf(“linked list is as follows\n”);

while (P!=NULL){

printf(” %d->”,P->inf);

P=P->Next;

}

}

Leave a Reply

Your email address will not be published. Required fields are marked *