Your first linux programs

Post on 16-Jul-2015

93 views 0 download

Transcript of Your first linux programs

Your First Linux

ProgramBY AHMED AL ZAIDY

Made Specially for Jones College

Students

INTRODUCTION TO UNIX

2015

PuTTY

You need to Download the PuTTYShell Program.

After Starting PuTTY Enter the Linux Server Information

Server Address: DLLinux.jones.edu

After That click on Open.

Enter your Username and Password

* Note you will NOT see the password typed into the Shell but complete the password and press Return (Enter).

Hello Word Program Source Code

First C Programming

Vi Editor

Type into the shell

vi hello.c

Copy the source code below.

#include<stdio.h>

void main()

{

printf("Hello! This is my first C

program with Ubuntu

11.10\n");

/* Do something more if you

want */

}

Hello Word Program Source Code

First C Programming

Vi Editor

Press ESC Button

Type into vi

:wq

To write the file and quite

type into the shell the code

gcc hello.c -o hello1

Then type

./hello1

Hello Word 2 Program Source Code

Second C Programming

VI Editor

Type into Shell

vi chapter1_2.c

Copy the text into the vi

Then press ESC

Type :wq

Then type into the shell

gcc -o hello2 chapter1_2.c

./hello2

./hello2 my name is ahmed

#include<stdio.h>

int main(int argc, char*argv[])

{

int i=0;

printf("hello, you are learning

C!!\n");

printf("Number of arguments

to the main function:%d\n, argc");

for(i=0; i&lt;argc; i++)

{

printf("argument number %d

is %s\n",i, argv[i]);

}

return 0;

}

A to Z Program Source Code

Third C Programming

VI Editor

Type into Shell

vi atoz.c

Copy the text into the vi

Then press ESC

Type :wq

Then type into the shell

gcc -o atoz1 atoz.c

./atoz1

#include <stdio.h>

int main()

{

char c;

for(c='A'; c<='Z'; ++c)

printf("%c ",c);

return 0;

}

Screen Shot First C Program

Screen Shot Second C Program

Screen Shot Third C Program

Ahmed Al Zaidyaalzaidy@jones.edu