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

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

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