Code Monkey home page Code Monkey logo

programming-in-c's Introduction

programming-in-c

Programming in C

Compiling a c program

  • Create an executable c program file and execute it.

Arrays

One dimensional array ( Vectors )

  • Syntax: int arrayVariableName[size];

  • Example one - int myNums[4]; // Here 4 is the size of the array, means this array can have upto four items.

  • Example two int myNums[] = {1, 4, 6, 8} // Because we are declaring and initiallzing the array at the same time, we don't need to specify the size 4.

Two Dimensional array ( Matrices )

  • Syntax: int arrayVariableName[rowsCount][columnsCount];

  • This two dimensional array has two rows and each row has 4 items(colums) in the array. You need to loop through it twice to print their values

  • Example: int myNums[2][4] = { {2, 3, 2, 1}, {2, 5, 4, 2}

  • Example Two:

#include<stdio.h> int main(){
int i=0,j=0;
int arr[4][3]={{1,2,3},{2,3,4},{3,4,5},{4,5,6}};

//Traversing 2D array
for(i=0;i<4;i++){
for(j=0;j<3;j++){
printf("arr[%d] [%d] = %d \n",i,j,arr[i][j]);
}//end of j
}//end of i
return 0;
}


<img width="1434" alt="image" src="https://user-images.githubusercontent.com/11497423/189525386-7f5d95f3-b800-49d3-afa8-fdeda3374afb.png">

programming-in-c's People

Contributors

imranhsayed avatar sumayyahc1 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sumayyahc1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.