programming in c
TRANSCRIPT
Practical Demonstration In Programming
In "C"
Presented By :Farhat AnjumHOD, Computer Sci.GDRCST
Contents …
Scheme of ExaminationSample Question Paper
Sample Solution with :
AlgorithmFlowchat
Source CodeOutput
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
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.
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
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
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();
}
Input & Output : Enter any positive no. : 5
Factorial of 5 is 120
Any Queries…..????
Thank You….