Sunday, September 6, 2015

Arithmetic Operations for 2 Dimensional array

Arithmetic Operations for 2 Dimensional array
#include<stdio.h>
#include<conio.h>
void fun(int a[][3],int b[][3],int n);
void main()
{
    int a[3][3],b[3][3],i,j,n,opt;

    {
        for(i=0; i<3; i++)
            for(j=0; j<3; j++)
            {
                printf("ENTER THE VALUE FOR A[%d][%d]",i,j);
                scanf("%d",&a[i][j]);
            }
        for(i=0; i<3; i++)
            for(j=0; j<3; j++)
            {
                printf("ENTER THE VALUE FOR B[%d][%d]",i,j);
                scanf("%d",&b[i][j]);
            }

        printf("\n THE MATRIX A IS \n");
        for(i=0; i<3; i++)
        {
            for(j=0; j<3; j++)
                printf("%d\t\t",a[i][j]);
            printf("\n");
        }
        printf("\n THE MATRIX B IS \n");
        for(i=0; i<3; i++)
        {
            for(j=0; j<3; j++)
                printf("%d\t\t",b[i][j]);
            printf("\n");
        }
    }
    printf("ENTER YOUR OPTION\n1 FOR ADDITION\n2 FOR SUBRACTION");
    printf("\n3 FOR MULTIPLICATION\n4 FOR MODULATION\n");
    scanf("%d",&opt);
    switch(opt)
    {
    case 1:
        fun(a,b,opt);
        break;
    case 2:
        fun(a,b,opt);
        break;
    case 3:
        fun(a,b,opt);
        break;
    case 4:
        fun(a,b,opt);
        break;
    default:
        printf("ENTER CORRECT VALUE");
    }
    getch();
}

void fun(int a[][3],int b[][3],int n)
{
    int c[3][3],i,j,k;
    if(n==1)
    {
        for(i=0; i<3; i++)
        {
            for(j=0; j<3; j++)
            {
                c[i][j]=a[i][j]+b[i][j];
                printf("%d\t",c[i][j]);
            }
            printf("\n");
        }
    }
    else if(n==2)
        for(i=0; i<3; i++)
        {
            for(j=0; j<3; j++)
            {
                c[i][j]=a[i][j]-b[i][j];
                printf("%d\t",c[i][j]);
            }
            printf("\n");
        }
    else if(n==3)
        for(i=0; i<3; i++)
        {
            for(j=0; j<3; j++)
            {
                c[i][j]=0;
                for(k=0; k<3; k++)
                    c[i][j]=c[i][j]+a[i][k]*b[k][j];
                printf("%d\t",c[i][j]);
            }
            printf("\n");
        }
    else
        for(i=0; i<3; i++)
        {
            for(j=0; j<3; j++)
            {
                c[i][j]=a[i][j]%b[i][j];
                printf("%d\t",c[i][j]);
            }
            printf("\n");
        }
}



output :

Arithmetic Operations


#include<stdio.h>
#include<conio.h>
void main()
{
int A,B;
char C='%';
clrscr();
printf("enter the values of A,B\n");
scanf("%d%d",&A,&B);
clrscr();
printf("OPERATOR   MEANING\tEXAMPLE\n");
printf("+          ADDITI\t%d+%d=%d\n",A,B,A+B);
printf("-          SUBTRA\t%d-%d=%d\n",A,B,A-B);
printf("*          MULTIP\t%d*%d=%d\n",A,B,A*B);
printf("/          DIVISI\t%d/%d=%d\n",A,B,A/B);
printf("%c          MODULU\t%d%c%d=%d\n",C,A,C,B,A%B);
getch();
}

Compiling C Program on Ubantu

Ubuntu has inbuilt(default) c compiler with name GCC(GNU C Compiler) so we don't have to use external applications in order to compile our programs

Steps to compile c program
1 . Open Terminal using  Ctrl - Alt + T 
2. Locate your 'c' file (if your new to Ubuntu then learn about commands from here
3. compile your program using
   gcc program.c             (program is name of your file )
   ./a.out                           (to display output )

Saturday, September 5, 2015

Quincy 2005

Quincy is freeware open-source. It is a simple programming environment for C/C++ on Windows. It contains an editor, a compiler, a debugger, and graphics and GUI toolkits.

Because of it's simple interface, Quincy is ideal for learning C or C++ programming.




Q ) How to write a program ?
A ) Open File → New → C Source File 
     Write your code and save before compile(dont forget to save with extension      for example example.c )

( note : Quincy doesnt take void main , so recomended to use int main() and return 0 to run program with out error)


Download Quincy 2005 here 

What is Compiler ?

A compiler is a computer program which converts source code into object code


or
compiler is a program that translates a source program written in some high-level programming language (such as Java) into machine code for some computer architecture (such as the Intel Pentium architecture). The generated machine code can be later executed many times against different data each time.

Code Blocks

CodeBlocks


Codeblocks is a cross-platform IDE built around wxWidgets, designed to be extensible and configurable. Runs on Windows and Linux.








Q ) How To Write A Program ?
A) → Open File → New → File... →Empty File → Go
     → On Next Screen you will see Empty file wizard , just click on next (You can click on "Skip this           page next time "radio box so that this window  wont disturb you again )
     → You need to enter file name  , just click on browse icon (...  box which is placed next to the                    name field) and you can choose specified location to save your program with your desired                    program name (dont forget to add extension as .c for example sample.c ) and click on Finish
     → All set , now you can write all your code there . 
     → For compiling goto build → Build and run    , you can see your output in new console window 
          
( note: clrscr();  is not required because your console window doesn't require to clear previous               data and if you use clrscr(); then code compiler display some error , so try to violate that                     function )
( note:You must close previous console window (if any) in-order to compile new program ) 

You can download this from their website →   Code:::Blocks



Monday, August 31, 2015

Hello World

Baisc C Program To Print Hello World

#include
void main()
{
clrscr();
printf("HELLO WORLD");
getch();
}


Saturday, August 29, 2015

About Me

Hai Friends
I am Muni Sai .I have completed my B.Tech on Electronics and Communication Engineering .
Though I studied Electronics and Communication Engineering, My Interest towards computers and Technology amplified my passion on programming .
I will post some C Programs in this blog which will be great helpful for you and all C Code that are presented in this blog is coded by myself so I will answer any doubts regarding Posts.

ThankYou