programming in c

10
Practical Demonstration In Programming In "C" Presented By : Farhat Anjum HOD, Computer Sci. GDRCST

Upload: csgdrcst

Post on 21-Mar-2017

63 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Programming in c

Practical Demonstration In Programming

In "C"

Presented By :Farhat AnjumHOD, Computer Sci.GDRCST

Page 2: Programming in c

Contents …

Scheme of ExaminationSample Question Paper

Sample Solution with :

AlgorithmFlowchat

Source CodeOutput

Page 3: Programming in c

Scheme of Examination

Max. Marks : 100 Duration : 3 Hours

Marks Distribution

Program 1 - 20 MarksProgram 2 - 20 MarksProgram 3 - 20 MarksViva - 25 Marks

[Pra.Copy + IR] – 15 Marks

Total - 100 Marks

Page 4: Programming in c

Sample Question PaperSet : A

Note : (i)Attempt any 3 Questions. (ii) All program with flowchart & algorithms.

Qu. 1: Write a program to print the following:AA BA B C

Qu. 2: Write a program to find the factorial of a given number.

Qu. 3: Write a program to use putw() & getw() in file handling.

Qu. 4: Write a program of Command Line Argument.

Page 5: Programming in c

Sample Solution : Set : A

Qu. 2: Write a program to find the factorial of a given number.

Algorithm : To find factorial of a number.

Step 1: [Take input for variable num]num=value

Step 2 : [Initialization]fact = 1, i = num

Step 3 : Repeat step 3 while (i>=1)i) fact = fact*Iii) i = i-1

Step 4 : [Display the value of fact]Print “Factorial is : ” fact

Step 5 : Exit

Page 6: Programming in c

Flow Chart: To find factorial of a number. START

Take Input for

numInitialize

fact = 1i = num

i>=1

fact = fact * ii=i-1

Print “Factorial is ” fact

STOP

False

True

Page 7: Programming in c

Source Code : // A program to find the factorial of a number. Documentation Section#include<stdio.h> // Header files ….. Link Section#include<conio.h>void main() // main function section{

int num,i,fact=1; // variable declaration & initializationclrscr(); // clear screenprintf(“Enter any positive no. : ”);scanf(“%d”,&num);i = num; //Logic to get factorial no. starts from herewhile(I >= 1){

fact = fact * i;i--;

} // Logic ends hereprintf(“Factorial of %d is %d”,num,fact);getch();

}

Page 8: Programming in c

Input & Output : Enter any positive no. : 5

Factorial of 5 is 120

Page 9: Programming in c

Any Queries…..????

Page 10: Programming in c

Thank You….