SlideShare ist ein Scribd-Unternehmen logo
1 von 25
TUANKU SULTANAH BAHIYAH POLYTECHNIC
ELECTRICAL ENGINEERING DEPARTMENT
EC201 – FUNDAMENTAL PROGRAMMING 1
SESION: JUN 2012

NAME

:

MATRIX NUM

:

COMPUTER
NUMBER
START TIME

:

END TIME

:

PRACTICAL SKILL
MARK

:

:

/ 100

EXPERIMENT 2
TITLE : DATA INPUT AND OUTPUT
Objectives
At the end of this lesson, students will be able to understand:
Input Output Statements
Function of input output statements.
a. printf() and puts()
b. scanf() and gets()
Use format specified in programs
Modify input output file in programs
Create input output operations.

1
Please read the instructions / questions carefully.

EXERCISE 1 (3 HOURS)
Exercise 1A
Write a program that uses four output statements to print the pattern of asterisks (*) shown
below:
******
******
**
**
******
******

* * *
* * *
* *
*
* *
* *
* *
* *
* *
* ** *
*

******
******
***
***
******
******
Source Code

//Exercise 1A
#include <stdio.h>
main()
{
printf("****** *** *** ******");
printf("n****** ** * ** ******");
printf("n **
**
** **");
printf("n **
**
** **");
printf("n******
**** ******");
printf("n******
*
******");
}

2
Exercise 1B
Use printf() function to write a program that prints your name, registration number, email
address and telephone number.
Source Code
#include<stdio.h>
main()
{
printf("Muhammad Muzzammil Bin Md Rasid n");
printf("16DET13F1112 n");
printf("muzzammil.rashid@gmail.com n");
printf("017-4408184 n");
printf("Muhammad Shahrizal Bin abdullah n");
printf("16DET13F1082 n");
printf("Haikal.mikail@yahoo.com n");
printf("017-5613319 n");
printf("Aliff Marican Bin Ibrahim Marican n");
printf("16DET13F1106 n");
printf("012-4428248 n");
printf("alip95@yahoo.com n");
printf("Muhamad Husaini bin Hilmi n");
printf("16DET13F1085n");
printf("husaini_potden@yahoo.comn");
printf("017-4236686 n");
return 0;
}

3
Exercise 1C
Use puts() function to write a program that prints your name, registration number, email
address and telephone number.
Source Code
#include<stdio.h>
main()
{
puts("Muhammad Muzzammil Bin Md Rasid n");
puts("16DET13F1112 n");
puts("muzzammil.rashid@gmail.com n");
puts("017-4408184 n");
puts("Muhammad Shahrizal Bin abdullah n");
puts("16DET13F1082 n");
puts("Haikal.mikail@yahoo.com n");
puts("017-5613319 n");
puts("Aliff Marican Bin Ibrahim Marican n");
puts("16DET13F1106n");
puts("012-4428248 n");
puts("alip95@yahoo.com n");
puts("Muhamad Husaini bin Hilmi n");
puts("16DET13F1085 n");
puts("husaini_potden@yahoo.com n");
puts("017-4236686 n");
return 0;
}

4
Exercise 1D
Fix the errors of the program below:
#include <stdio.h>
main()
{
char addresS [200];
puts("Insert your full address: ");
getchs (Address);
printf ("Your address is: %k n",address);
return ();
}

The output after the errors fixed is shown as below:

5
Source Code
//Exercise 1D
#include<stdio.h>
main()
{
char address[200];
puts("Insert your full address");
gets(address);
printf("Your address is :%sn",address);
return 0;
}

6
Exercise 1E:
A

C program contains the following statements:

#include <stdio.h>
Int I,j,k;
Write an appropriate scanf function to enter numerical values for I,j and k, assuming
(a)

The values for I,j and k will be decimal integers.

#include<stdio.h>
main()
{
int i,j,k;
printf("Insert value of i:n");
scanf("%d",&i);
printf("Insert value of j:n");
scanf("%d",&j);
printf("Insert value of k:n");
scanf("%d",&k);
return 0;
}

7
(b)

The values I will be decimal integer, j an octal integer and k a hexadecimal integer.
#include<stdio.h>
main()
{
int i,j,k;
printf("Insert value of i:n");
scanf("%d",&i);
printf("Insert value of j:n");
scanf("%f",&j);
printf("Insert value of k:n");
scanf("%f",&k);
return 0;
}

8
(c)

The values for I and j will be hexadecimal integers and k will be an octal integer.
#include<stdio.h>
main()
{
int i,j,k;
printf("Insert value of i:n");
scanf("%f",&i);
printf("Insert value of j:n");
scanf("%f",&j);
printf("Insert value of k:n");
scanf("%f",&k);
return 0;
}

9
EXERCISE 2 ( 3 HOURS)
Exercise 2A:
Write the program and get the output.

//Exercise 2A
#include <stdio.h>
main()
{
char name [20];
int num1,num2,answer;
printf("Insert your name: ");
scanf("%s",&name);
printf("Enter your first integer:n");
scanf("%d",&num1);
printf("Enter your second integer:n");
scanf("%d",&num2);
answer=num1+num2;
printf("The sum is : %dn",answer);
return 0;
}

10
Exercise 2B
Modify the add.c program;
i.

Subtraction of num1 and num2, then display the answer
Source Code

#include <stdio.h>
main()
{
char name [20];
int num1,num2,answer;
printf("Insert your name: ");
scanf("%s",&name);
printf("Enter your first integer:n");
scanf("%d",&num1);
printf("Enter your second integer:n");
scanf("%d",&num2);
answer=num1-num2;
printf("The sum is : %dn",answer);
return 0;
}

11
ii.

Multiplication of num1 and num2, then display the answer
Source Code

#include <stdio.h>
main()
{
char name [20];
int num1,num2,answer;
printf("Insert your name: ");
scanf("%s",&name);
printf("Enter your first integer:n");
scanf("%d",&num1);
printf("Enter your second integer:n");
scanf("%d",&num2);
answer=num1*num2;
printf("The sum is : %dn",answer);
return 0;
}

12
iii.

Division of num1 and num2, then display the answer
Source Code

#include <stdio.h>
main()
{
char name [20];
double num1,num2,answer;
printf("Insert your name: ");
scanf("%s",&name);
printf("Enter your first integer:n");
scanf("%d",&num1);
printf("Enter your second integer:n");
scanf("%d",&num2);
answer=num1/num2;
printf("The sum is : %fn",answer);
return 0;
}

13
Exercise 2C
A C program contain s the following statement:
#include <stdio.h>
int a=0177,b=055,c=0xa8,d=0x1ff;

Write a printf function for each of the following groups of variables or expressions.
(a)

a,b,c and d
#include <stdio.h>
main()
{
int a=0177 , b=055 , c=0xa8 , d=0x1ff;
printf("a=0177 n");
printf("b=055 n");
printf("c=0xa8 n");
printf("d=0x1ff n");

return 0;
}

14
(b)

(a+b), (c-d)

#include <stdio.h>

main()
{
int a=0177 , b=055 , c=0xa8 , d=0x1ff;
printf("a=0177 n");
printf("b=055 n");
printf("c=0xa8 n");
printf("d=0x1ff n");
printf("(a+b), (c-d) n");
printf("(0177+055), (0xa8-0x1ff)");

return 0;
}

15
Exercise 2D
Write a program that prompts the user to enter three numbers and then prints them vertically
(each in one line), first forward and then reversed (the last one first), as shown below.

16
Source Code
#include <stdio.h>
main()
{
printf("Enter 3 integer : n");
printf("12 n");
printf("56 n");
printf("89 n");
printf("forward order 12 -> 56 -> 89 n");
printf("reversed order 89 <- 56 <- 12 ");
return 0;
}

17
EXERCISE 3 ( 3 HOURS)

Exercise 3A
By using the six steps in C programming, please make a program that can calculate voltage
value using Ohms Law.
The sample of output you should get as shown below:

*** Please make sure all the steps in problem solving are accurate and complete discussed.

18
#include<stdio.h>
main()
{
float resistance,current,voltage;
printf("---Ohm's Law---n");
printf("Enter resistance in Ohmn");
scanf("%f",&resistance);
printf("Enter current in Amperen");
scanf("%f",&current);
printf("Enter value of the Voltagen");
scanf("%f",&voltage);

return 0;
}

19
Exercise 3B
By using the six steps in C programming, please make a program that can calculate the volume
and area of sphere.
The sample of output you should get as shown below:

*** Please make sure all the steps in problem solving are accurate and complete discussed

20
#include<stdio.h>
#define PI 3.142
main()
{
float radius,volume,area;
printf("Please enter the value for a radius:n");
scanf("%f",&radius);
area = 1.33*PI*(radius*radius*radius);
printf("the volume is:%fn",area);
volume = 4*PI*(radius*radius);
printf("the area is:%f",volume);
return 0;
}

21
Exercise 3C
By using the six steps in C programming, please make a program that can find odd or even
using conditional operator.

The sample of output you should get as shown below:

*** Please make sure all the steps in problem solving are accurate and complete discussed

22
#include<stdio.h>

main()

{
printf("Enter an integern");
printf("5n");
printf(Odd numbernn");

return 0;

}

23
#include<stdio.h>

main()

{
printf("Enter an integern");
printf("6n");
printf("Even numbernn");

return 0;

}

24
PRACTICAL SKILL ASSESSMENT RUBRIC (CLO 4)
EXPERIMENT 2

1.Specifications

2.Readability

3.Error

/5

Exercise

/5

/5

4.Concept
Understanding
/5

5.Delivery

Total

/5

/25

1A
1B
1C
1D
1E
2A
2B
2C
2D
3A
3B
3C
Total Marks (( Total Mark/300)*100)

/300
/100

25

Weitere ähnliche Inhalte

Was ist angesagt?

Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given numberMainak Sasmal
 
Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manualAnil Bishnoi
 
Compiler design lab
Compiler design labCompiler design lab
Compiler design labilias ahmed
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given numberMainak Sasmal
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 SolutionHazrat Bilal
 
Simple c program
Simple c programSimple c program
Simple c programRavi Singh
 
Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7alish sha
 
Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Hazrat Bilal
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7Rumman Ansari
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in cSaranya saran
 
C Language Programs
C Language Programs C Language Programs
C Language Programs Mansi Tyagi
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branchingSaranya saran
 
C programs
C programsC programs
C programsMinu S
 

Was ist angesagt? (20)

Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
 
week-3x
week-3xweek-3x
week-3x
 
Compiler design lab
Compiler design labCompiler design lab
Compiler design lab
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Compiler design lab programs
Compiler design lab programs Compiler design lab programs
Compiler design lab programs
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
 
Simple c program
Simple c programSimple c program
Simple c program
 
Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 
C Programming
C ProgrammingC Programming
C Programming
 
Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
C programs
C programsC programs
C programs
 

Andere mochten auch

Private cloud without the hassle
Private cloud without the hasslePrivate cloud without the hassle
Private cloud without the hassleColin J. O'Sullivan
 
3927 IIJ - Programme Guide 2015-v8
3927 IIJ - Programme Guide 2015-v83927 IIJ - Programme Guide 2015-v8
3927 IIJ - Programme Guide 2015-v8Colin J. O'Sullivan
 
Market research results analysis
Market research results analysisMarket research results analysis
Market research results analysismarykatekenny
 
Most Beautiful Deck On SlideShare - Brides Of India
Most Beautiful Deck On SlideShare - Brides Of IndiaMost Beautiful Deck On SlideShare - Brides Of India
Most Beautiful Deck On SlideShare - Brides Of IndiaMalabar Gold And Diamonds
 
Draycir infographic hr
Draycir infographic hrDraycir infographic hr
Draycir infographic hrDraycir Ltd
 
Dani calfornia’ red hot chilli peppers
Dani calfornia’  red hot chilli peppersDani calfornia’  red hot chilli peppers
Dani calfornia’ red hot chilli peppersmarykatekenny
 
Vicky Pelka's Training Session On Impact Evaluation
Vicky Pelka's Training Session On Impact EvaluationVicky Pelka's Training Session On Impact Evaluation
Vicky Pelka's Training Session On Impact EvaluationJosh Chandler
 

Andere mochten auch (16)

Private cloud without the hassle
Private cloud without the hasslePrivate cloud without the hassle
Private cloud without the hassle
 
Six Ways To Have The Coolest Wedding Ever
Six Ways To Have The Coolest Wedding EverSix Ways To Have The Coolest Wedding Ever
Six Ways To Have The Coolest Wedding Ever
 
Question 2 comp
Question 2 compQuestion 2 comp
Question 2 comp
 
Market research
Market researchMarket research
Market research
 
Image analysis
Image analysisImage analysis
Image analysis
 
Question 3
Question 3Question 3
Question 3
 
Market Research
Market ResearchMarket Research
Market Research
 
3927 IIJ - Programme Guide 2015-v8
3927 IIJ - Programme Guide 2015-v83927 IIJ - Programme Guide 2015-v8
3927 IIJ - Programme Guide 2015-v8
 
Production Diary
Production DiaryProduction Diary
Production Diary
 
Market research results analysis
Market research results analysisMarket research results analysis
Market research results analysis
 
Most Beautiful Deck On SlideShare - Brides Of India
Most Beautiful Deck On SlideShare - Brides Of IndiaMost Beautiful Deck On SlideShare - Brides Of India
Most Beautiful Deck On SlideShare - Brides Of India
 
Draycir infographic hr
Draycir infographic hrDraycir infographic hr
Draycir infographic hr
 
Dani calfornia’ red hot chilli peppers
Dani calfornia’  red hot chilli peppersDani calfornia’  red hot chilli peppers
Dani calfornia’ red hot chilli peppers
 
She Is Mine - The Underlying Thought
She Is Mine -  The Underlying ThoughtShe Is Mine -  The Underlying Thought
She Is Mine - The Underlying Thought
 
Top 10 gifts and their hidden message
Top 10 gifts and their hidden messageTop 10 gifts and their hidden message
Top 10 gifts and their hidden message
 
Vicky Pelka's Training Session On Impact Evaluation
Vicky Pelka's Training Session On Impact EvaluationVicky Pelka's Training Session On Impact Evaluation
Vicky Pelka's Training Session On Impact Evaluation
 

Ähnlich wie Muzzammilrashid

Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9alish sha
 
Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10alish sha
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3alish sha
 
C Language Programming Introduction Lecture
C Language Programming Introduction LectureC Language Programming Introduction Lecture
C Language Programming Introduction Lecturemyinstalab
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]Abhishek Sinha
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04hassaanciit
 
C- Programming Assignment 4 solution
C- Programming Assignment 4 solutionC- Programming Assignment 4 solution
C- Programming Assignment 4 solutionAnimesh Chaturvedi
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxtristans3
 

Ähnlich wie Muzzammilrashid (20)

UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
Dti2143 lab sheet 9
Dti2143 lab sheet 9Dti2143 lab sheet 9
Dti2143 lab sheet 9
 
C programs
C programsC programs
C programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10
 
C lab
C labC lab
C lab
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3
 
C file
C fileC file
C file
 
C Language Programming Introduction Lecture
C Language Programming Introduction LectureC Language Programming Introduction Lecture
C Language Programming Introduction Lecture
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04
 
C programming
C programmingC programming
C programming
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
C- Programming Assignment 4 solution
C- Programming Assignment 4 solutionC- Programming Assignment 4 solution
C- Programming Assignment 4 solution
 
C- Programming Assignment 3
C- Programming Assignment 3C- Programming Assignment 3
C- Programming Assignment 3
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 

Kürzlich hochgeladen

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Kürzlich hochgeladen (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Muzzammilrashid

  • 1. TUANKU SULTANAH BAHIYAH POLYTECHNIC ELECTRICAL ENGINEERING DEPARTMENT EC201 – FUNDAMENTAL PROGRAMMING 1 SESION: JUN 2012 NAME : MATRIX NUM : COMPUTER NUMBER START TIME : END TIME : PRACTICAL SKILL MARK : : / 100 EXPERIMENT 2 TITLE : DATA INPUT AND OUTPUT Objectives At the end of this lesson, students will be able to understand: Input Output Statements Function of input output statements. a. printf() and puts() b. scanf() and gets() Use format specified in programs Modify input output file in programs Create input output operations. 1
  • 2. Please read the instructions / questions carefully. EXERCISE 1 (3 HOURS) Exercise 1A Write a program that uses four output statements to print the pattern of asterisks (*) shown below: ****** ****** ** ** ****** ****** * * * * * * * * * * * * * * * * * * * * ** * * ****** ****** *** *** ****** ****** Source Code //Exercise 1A #include <stdio.h> main() { printf("****** *** *** ******"); printf("n****** ** * ** ******"); printf("n ** ** ** **"); printf("n ** ** ** **"); printf("n****** **** ******"); printf("n****** * ******"); } 2
  • 3. Exercise 1B Use printf() function to write a program that prints your name, registration number, email address and telephone number. Source Code #include<stdio.h> main() { printf("Muhammad Muzzammil Bin Md Rasid n"); printf("16DET13F1112 n"); printf("muzzammil.rashid@gmail.com n"); printf("017-4408184 n"); printf("Muhammad Shahrizal Bin abdullah n"); printf("16DET13F1082 n"); printf("Haikal.mikail@yahoo.com n"); printf("017-5613319 n"); printf("Aliff Marican Bin Ibrahim Marican n"); printf("16DET13F1106 n"); printf("012-4428248 n"); printf("alip95@yahoo.com n"); printf("Muhamad Husaini bin Hilmi n"); printf("16DET13F1085n"); printf("husaini_potden@yahoo.comn"); printf("017-4236686 n"); return 0; } 3
  • 4. Exercise 1C Use puts() function to write a program that prints your name, registration number, email address and telephone number. Source Code #include<stdio.h> main() { puts("Muhammad Muzzammil Bin Md Rasid n"); puts("16DET13F1112 n"); puts("muzzammil.rashid@gmail.com n"); puts("017-4408184 n"); puts("Muhammad Shahrizal Bin abdullah n"); puts("16DET13F1082 n"); puts("Haikal.mikail@yahoo.com n"); puts("017-5613319 n"); puts("Aliff Marican Bin Ibrahim Marican n"); puts("16DET13F1106n"); puts("012-4428248 n"); puts("alip95@yahoo.com n"); puts("Muhamad Husaini bin Hilmi n"); puts("16DET13F1085 n"); puts("husaini_potden@yahoo.com n"); puts("017-4236686 n"); return 0; } 4
  • 5. Exercise 1D Fix the errors of the program below: #include <stdio.h> main() { char addresS [200]; puts("Insert your full address: "); getchs (Address); printf ("Your address is: %k n",address); return (); } The output after the errors fixed is shown as below: 5
  • 6. Source Code //Exercise 1D #include<stdio.h> main() { char address[200]; puts("Insert your full address"); gets(address); printf("Your address is :%sn",address); return 0; } 6
  • 7. Exercise 1E: A C program contains the following statements: #include <stdio.h> Int I,j,k; Write an appropriate scanf function to enter numerical values for I,j and k, assuming (a) The values for I,j and k will be decimal integers. #include<stdio.h> main() { int i,j,k; printf("Insert value of i:n"); scanf("%d",&i); printf("Insert value of j:n"); scanf("%d",&j); printf("Insert value of k:n"); scanf("%d",&k); return 0; } 7
  • 8. (b) The values I will be decimal integer, j an octal integer and k a hexadecimal integer. #include<stdio.h> main() { int i,j,k; printf("Insert value of i:n"); scanf("%d",&i); printf("Insert value of j:n"); scanf("%f",&j); printf("Insert value of k:n"); scanf("%f",&k); return 0; } 8
  • 9. (c) The values for I and j will be hexadecimal integers and k will be an octal integer. #include<stdio.h> main() { int i,j,k; printf("Insert value of i:n"); scanf("%f",&i); printf("Insert value of j:n"); scanf("%f",&j); printf("Insert value of k:n"); scanf("%f",&k); return 0; } 9
  • 10. EXERCISE 2 ( 3 HOURS) Exercise 2A: Write the program and get the output. //Exercise 2A #include <stdio.h> main() { char name [20]; int num1,num2,answer; printf("Insert your name: "); scanf("%s",&name); printf("Enter your first integer:n"); scanf("%d",&num1); printf("Enter your second integer:n"); scanf("%d",&num2); answer=num1+num2; printf("The sum is : %dn",answer); return 0; } 10
  • 11. Exercise 2B Modify the add.c program; i. Subtraction of num1 and num2, then display the answer Source Code #include <stdio.h> main() { char name [20]; int num1,num2,answer; printf("Insert your name: "); scanf("%s",&name); printf("Enter your first integer:n"); scanf("%d",&num1); printf("Enter your second integer:n"); scanf("%d",&num2); answer=num1-num2; printf("The sum is : %dn",answer); return 0; } 11
  • 12. ii. Multiplication of num1 and num2, then display the answer Source Code #include <stdio.h> main() { char name [20]; int num1,num2,answer; printf("Insert your name: "); scanf("%s",&name); printf("Enter your first integer:n"); scanf("%d",&num1); printf("Enter your second integer:n"); scanf("%d",&num2); answer=num1*num2; printf("The sum is : %dn",answer); return 0; } 12
  • 13. iii. Division of num1 and num2, then display the answer Source Code #include <stdio.h> main() { char name [20]; double num1,num2,answer; printf("Insert your name: "); scanf("%s",&name); printf("Enter your first integer:n"); scanf("%d",&num1); printf("Enter your second integer:n"); scanf("%d",&num2); answer=num1/num2; printf("The sum is : %fn",answer); return 0; } 13
  • 14. Exercise 2C A C program contain s the following statement: #include <stdio.h> int a=0177,b=055,c=0xa8,d=0x1ff; Write a printf function for each of the following groups of variables or expressions. (a) a,b,c and d #include <stdio.h> main() { int a=0177 , b=055 , c=0xa8 , d=0x1ff; printf("a=0177 n"); printf("b=055 n"); printf("c=0xa8 n"); printf("d=0x1ff n"); return 0; } 14
  • 15. (b) (a+b), (c-d) #include <stdio.h> main() { int a=0177 , b=055 , c=0xa8 , d=0x1ff; printf("a=0177 n"); printf("b=055 n"); printf("c=0xa8 n"); printf("d=0x1ff n"); printf("(a+b), (c-d) n"); printf("(0177+055), (0xa8-0x1ff)"); return 0; } 15
  • 16. Exercise 2D Write a program that prompts the user to enter three numbers and then prints them vertically (each in one line), first forward and then reversed (the last one first), as shown below. 16
  • 17. Source Code #include <stdio.h> main() { printf("Enter 3 integer : n"); printf("12 n"); printf("56 n"); printf("89 n"); printf("forward order 12 -> 56 -> 89 n"); printf("reversed order 89 <- 56 <- 12 "); return 0; } 17
  • 18. EXERCISE 3 ( 3 HOURS) Exercise 3A By using the six steps in C programming, please make a program that can calculate voltage value using Ohms Law. The sample of output you should get as shown below: *** Please make sure all the steps in problem solving are accurate and complete discussed. 18
  • 19. #include<stdio.h> main() { float resistance,current,voltage; printf("---Ohm's Law---n"); printf("Enter resistance in Ohmn"); scanf("%f",&resistance); printf("Enter current in Amperen"); scanf("%f",&current); printf("Enter value of the Voltagen"); scanf("%f",&voltage); return 0; } 19
  • 20. Exercise 3B By using the six steps in C programming, please make a program that can calculate the volume and area of sphere. The sample of output you should get as shown below: *** Please make sure all the steps in problem solving are accurate and complete discussed 20
  • 21. #include<stdio.h> #define PI 3.142 main() { float radius,volume,area; printf("Please enter the value for a radius:n"); scanf("%f",&radius); area = 1.33*PI*(radius*radius*radius); printf("the volume is:%fn",area); volume = 4*PI*(radius*radius); printf("the area is:%f",volume); return 0; } 21
  • 22. Exercise 3C By using the six steps in C programming, please make a program that can find odd or even using conditional operator. The sample of output you should get as shown below: *** Please make sure all the steps in problem solving are accurate and complete discussed 22
  • 25. PRACTICAL SKILL ASSESSMENT RUBRIC (CLO 4) EXPERIMENT 2 1.Specifications 2.Readability 3.Error /5 Exercise /5 /5 4.Concept Understanding /5 5.Delivery Total /5 /25 1A 1B 1C 1D 1E 2A 2B 2C 2D 3A 3B 3C Total Marks (( Total Mark/300)*100) /300 /100 25