programming language 1 - wordpress.com · programming language 1 functions pointer array string...

63
PROGRAMMING LANGUAGE 1 FUNCTIONS POINTER ARRAY STRING STRUCTURE AMERICAN INTERNATIONAL UNIVERSITY- BANGLADESH where leaders are created CSC-1102 Course name: Course code: BASIC C NORMAL PROGRAMS IF-ELSE STATEMENTS LOOP PATTERN PRINTING CODES OF WHOLE SEMESTER FROM CLASSES ----------------------------------------------------- ----------------------------------------------------- VERSION: 1.OO TOPICS Solution by: JUBAYER, SADAT (17-*****-2) Released on 25 th august, 2017

Upload: others

Post on 02-Aug-2020

18 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

PROGRAMMING LANGUAGE 1

FUNCTIONS

POINTER

ARRAY

STRING

STRUCTURE

AMERICAN INTERNATIONAL UNIVERSITY- BANGLADESH where leaders are created

CSC-1102

Course name:

Course code:

BASIC C

NORMAL PROGRAMS

IF-ELSE STATEMENTS

LOOP

PATTERN PRINTING

CODES OF WHOLE SEMESTER FROM CLASSES -----------------------------------------------------

----------------------------------------------------- VERSION: 1.OO

TOPICS

Solution by: JUBAYER, SADAT (17-*****-2)

Released on 25th august, 2017

Page 2: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

All codes are Checked and Compiled by

Feel free to contact me if you have any problem or query

EMAIL [email protected]

FACEBOOK Fb.me/SadatJubayer

LinkedIn linkedin.com/in/sadatjubayer/

GITHUB Github.com/SadatJubayer

SADAT JUBAYER

Special THANKS to our respected faculty:

SHAHRIN CHOWDHURY Three free Advices Hai, Lena hai toh Lo, Nahi toh Jaane do..!

Don’t memorize codes, try to understand the concept. Type codes by your own hand instead of copy-pasting.

Learn coding to become a Programmer, not for getting A+ on the exams.

Page 3: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

Basic C-Programming

*Printing Hello World

*Printing Hello World (in separate lines)

Solution by: JUBAYER, SADAT PAGE NO. 01

Page 4: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Take a number from keyboard and print that

*Take two number as input and print the sum of the numbers

Solution by: JUBAYER, SADAT PAGE NO. 02

Page 5: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Multiplication of two integer and two float numbers

*a and b as integer, c and d as float. Find- (a+b)/(c+d)

Solution by: JUBAYER, SADAT PAGE NO. 03

Page 6: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Swapping two integer numbers

*Celsius to Fahrenheit conversion

Solution by: JUBAYER, SADAT PAGE NO. 04

Page 7: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Take 3 integer numbers as input and print their reverse number

*Take 5 integer numbers as input and print their reverse number

Solution by: JUBAYER, SADAT PAGE NO. 05

Page 8: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Take 5 subjects’ marks as input and find the sum of marks

*KG to Pound conversion

Solution by: JUBAYER, SADAT PAGE NO. 06

Page 9: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Take 5 Digit number as input and find the sum of the Digits

Solution by: JUBAYER, SADAT PAGE NO. 07

Page 10: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

If-else statements

*Take year as input, if it’s bigger than 25, print ‘bonus 2500’ else print

‘No bonus’

*Check Even number or Odd number

Solution by: JUBAYER, SADAT PAGE NO. 08

Page 11: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Finding youngest one form three people’s age

Solution by: JUBAYER, SADAT PAGE NO. 09

Page 12: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Checking eligibility of Joining Army

Recruitment for male Recruitment for female

Age: 18 to 21

Height: 5.5+

Weight: 50+

Marital status: Single

Age: 18 to 21

Height: 5.2+

Weight: 45+

Marital status: Single

Solution by: JUBAYER, SADAT PAGE NO. 10

Page 13: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Checking worker efficiency form working hours

In a company, worker efficiency is determined on the basis of the time required for a worker to complete a particular job. If the time taken by the worker is between 2 – 3 hours, then the worker is said to be highly efficient. If the time required by the worker is between 3 – 4 hours, then the worker is ordered to improve speed. If the time taken is between 4 – 5 hours, the worker is given training to improve his speed, and if the time taken by the worker is more than 5 hours, then the worker has to leave the company. If the time taken by the worker is input through the keyboard, find the efficiency of the worker.

Solution by: JUBAYER, SADAT PAGE NO. 11

Page 14: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Checking year: Leap year or not

*Checking year: Leap year or not (using logical operator)

Solution by: JUBAYER, SADAT PAGE NO. 12

Page 15: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Checking Letter: Vowel/Consonant

Solution by: JUBAYER, SADAT PAGE NO. 13

Page 16: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

LOOP

*Sum of 1 to 100 (using loop)

*Sum of odd numbers between 1 to 100 (using loop)

Solution by: JUBAYER, SADAT PAGE NO. 14

Page 17: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Sum of even numbers between 1 to 100 (using loop)

*15 employees, if extra hour is more than 40 will get 600 per extra

hour, otherwise no bonus.

Solution by: JUBAYER, SADAT PAGE NO. 15

Page 18: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Factorial of a Number

*Checking number: Prime number or Not

Solution by: JUBAYER, SADAT PAGE NO. 16

Page 19: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Print prime numbers (1 to 100)

Solution by: JUBAYER, SADAT PAGE NO. 17

Page 20: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Finding out Fibonacci Numbers:

*Checking number: Palindrome or not

Solution by: JUBAYER, SADAT PAGE NO. 18

Page 21: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

PYRAMID PRINTING

*Printing this:

Number of Line N=3

*

* *

* * *

Number of Line N=5

*

* *

* * *

* * * * * * * * *

Solution by: JUBAYER, SADAT PAGE NO. 19

Page 22: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Printing this:

Number of Line N=3

* * *

* *

*

Number of Line N=5

* * * * *

* * * *

* * * * *

*

Solution by: JUBAYER, SADAT PAGE NO. 20

Page 23: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Printing this:

Number of Line N=3

1

1 2

1 2 3

Number of Line N=5

1

1 2

1 2 3 1 2 3 4 1 2 3 4 5

Solution by: JUBAYER, SADAT PAGE NO. 21

Page 24: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Printing this:

Number of Line N=3

1 2 3

1 2

1

Number of Line N=5

1 2 3 4 5

1 2 3 4

1 2 3 2 2

1

Solution by: JUBAYER, SADAT PAGE NO. 22

Page 25: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

MORE PATTERNS

*Printing this:

Number of Line N=3

1 1 2 1

1 2 3 2 1

Number of Line N=4

1 1 2 1

1 2 3 2 1

1 2 3 4 3 2 1

Solution by: JUBAYER, SADAT PAGE NO. 23

Page 26: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Printing this:

Number of Line N=3

1 1 2 3

1 2 3 4 5

Number of Line N=4

1 1 2 3

1 2 3 4 5

1 2 3 4 5 6 7

Solution by: JUBAYER, SADAT PAGE NO. 24

Page 27: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Printing this: (Floyd’s Triangle)

Number of Line N=3

1 2 3 4

5 6 7 8 9

Number of Line N=4

1 2 3 4

5 6 7 8 9

10 11 12 13 14 15 16

Solution by: JUBAYER, SADAT PAGE NO. 25

Page 28: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Printing this:

Number of Line N=3

1

3 2 1

4 3 2 1

Number of Line N=4

1

3 2 1

4 3 2 1

5 4 3 2 1

Solution by: JUBAYER, SADAT PAGE NO. 26

Page 29: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

Functions

*Summation, Subtraction, Multiply, Division using Function

Solution by: JUBAYER, SADAT PAGE NO. 27

Page 30: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Printing Patterns (using Function)

Solution by: JUBAYER, SADAT PAGE NO. 28

Page 31: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Finding bonus from extra working hours (using function)

Solution by: JUBAYER, SADAT PAGE NO. 29

Page 32: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Palindrome or not (using Function)

Solution by: JUBAYER, SADAT PAGE NO. 30

Page 33: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Swapping number using function

Solution by: JUBAYER, SADAT PAGE NO. 31

Page 34: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

Pointer

*Swapping using pointer

Solution by: JUBAYER, SADAT PAGE NO. 32

Page 35: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Output of *, &, ** , *(*), &(*)

Output:

Solution by: JUBAYER, SADAT PAGE NO. 33

Page 36: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Finding Radius using pointer

Solution by: JUBAYER, SADAT PAGE NO. 34

Page 37: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Palindrome or not using function and Pointer

Solution by: JUBAYER, SADAT PAGE NO. 35

Page 38: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Checking Index using Pointer

Solution by: JUBAYER, SADAT PAGE NO. 36

Page 39: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

Array

*Finding maximum, minimum and delete

Solution by: JUBAYER, SADAT PAGE NO. 37

Page 40: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Finding maximum, minimum and difference of them

Solution by: JUBAYER, SADAT PAGE NO. 38

Page 41: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Finding a Number from Array [1D array]

Solution by: JUBAYER, SADAT PAGE NO. 39

Page 42: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Finding a number from 2D array

Solution by: JUBAYER, SADAT PAGE NO. 40

Page 43: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Separate even and odd numbers from 2D array

Solution by: JUBAYER, SADAT PAGE NO. 41

Page 44: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Number deletion from Array

Solution by: JUBAYER, SADAT PAGE NO. 42

Page 45: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Finding number and replace from Array

Solution by: JUBAYER, SADAT PAGE NO. 43

Page 46: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Take 10 elements from keyboard and add 7 to each element and print

the result

Solution by: JUBAYER, SADAT PAGE NO. 44

Page 47: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

String

String Copy:

String Compare:

Solution by: JUBAYER, SADAT PAGE NO. 45

Page 48: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

String Compare (Limited):

String Length:

Solution by: JUBAYER, SADAT PAGE NO. 46

Page 49: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

String Concat:

String Reverse:

Solution by: JUBAYER, SADAT PAGE NO. 47

Page 50: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

Normal Codes and Function Codes of Strings

**Strncpy**

Normal Format

Function Format

Solution by: JUBAYER, SADAT PAGE NO. 48

Page 51: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

**Strlen**

Normal Format

Function Format

Solution by: JUBAYER, SADAT PAGE NO. 49

Page 52: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

**Strcmp**

Normal Format

Function Format

Solution by: JUBAYER, SADAT PAGE NO. 50

Page 53: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

**Strrev**

Normal Format

Function Format

Solution by: JUBAYER, SADAT PAGE NO. 51

Page 54: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

**Concat**

Normal Format

Function Format

Solution by: JUBAYER, SADAT PAGE NO. 52

Page 55: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Output Finding: 1

Solution by: JUBAYER, SADAT PAGE NO. 53

Page 56: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Output Finding: 2

Solution by: JUBAYER, SADAT PAGE NO. 54

Page 57: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

Structure

Normal scan-print

Scan-print using structure

Solution by: JUBAYER, SADAT PAGE NO. 55

Page 58: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

* Student’s name, department, course, roll and joying year as input &

Printing Name of the students who joined 2017(Using structure)

Solution by: JUBAYER, SADAT PAGE NO. 56

Page 59: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

* 8 Student’s name, department, course, roll and joying year, marks as

Input & Printing Name of the students who joined 2017 and also print

Average mark of the students (Using structure)

Solution by: JUBAYER, SADAT PAGE NO. 57

Page 60: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Print-Scan using Nested Structure

Solution by: JUBAYER, SADAT PAGE NO. 58

Page 61: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

*Nested structure (Finding Output)

Output:

Sadat 01754422008 Dhaka 1122

Solution by: JUBAYER, SADAT PAGE NO. 59

Page 62: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

Value and Pointer on Structure

Solution by: JUBAYER, SADAT PAGE NO. 60

Page 63: Programming Language 1 - WordPress.com · programming language 1 functions pointer array string structure american international university- bangladesh where leaders are created csc-1102

Recursion

--- End ---

Solution by: JUBAYER, SADAT PAGE NO. 61

Ye To Bas Shuruaat Hai

Picture Abhi Baaki Hai!

Programming Language 2 is

coming on next semester with C++