Skip to main content

FACTORIAL C CODE


  Q1Write a C program to print Factorial of a number as an output?


 Using Goto:


 #include<conio.h>                                
 #include<stdio.h>                                 
 void main()                                           
 {                                                           
 int n;                                                     
 int s=1;                                                 
 clrscr();                                                 
 scanf("%d",&n);                                    
 printf("\nthe number is=%d",n);            
 again :                                                  
 if(n>1)                                                   
 {                                                            
 s=s*n;                                                   
 n=n-1;                                                   
 goto again;                                            
 }                                                             
 printf("\nfactorial of no.- %d=\t%d",n,s);
 getch();                                                  
 }                                                             

 Using For loop:


 #include<conio.h>                                 
 #include<stdio.h>                                  
 void main()                                            
 {                                                             
 //factorial number                                  
 int n,i;                                                    
 int f=1;                                                   
 clrscr();                                                  
 scanf("%d",&n);                                     
 printf("\n\nthe number is=%d",n);          
 for(i=1;i<=n;i++)                                     
 {                                                               
 f=f*i;                                                        
 }                                                              
 printf("\n\nfactorial of no. %d = %d",n,f);
 getch();                                                   
 }                                                              

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

Sample Output:








Comments

Popular posts from this blog

DATA STRUCTURE SYLLABUS

Data Structures  
SECTION-A 
1. Basic Concepts and Notations, Introduction to Complexity, Data Structure and Data Structure operations. Applications of Data Structure. Basic data Structures: Arrays: Introduction, Types of Array, Memory representation, Applications and operations. Stacks and queue: Introduction, memory representation, Applications and operations 
(No. of Periods : 15) 
SECTION-B 
 2. Linked List: Operations:-traversing, searching, inserting, deleting, operations on header linked list, circular linked list, doubly linked list, memory representation, Applications, polynomial manipulation. 
( No. of Periods : 15) 
SECTION-C 

3. Trees – Definition and Basic concepts, Representation in Contiguous Storage, Binary Tree, Binary Tree Traversal, Searching, Insertion and deletion in Binary trees, Binary Search tree, AVL trees.
 (No. of Periods : 15)
 SECTION-D
4. Searching: Binary and Linear Search. Sorting: Bubble sort, Insertion sort, Selection sort, Merge Sort, Radix sort, Quick sort, S…

COMPUTER BASED NUMERICAL & METHOD(CONM) Syllabus

SyllabusBCA-2nd Year: SECTION-A 
 1. Computer Arithmetic :Floating Point Numbers, operations, normalizations and    their consequences, Errors and its types. 
 2. Iterative Methods :Bisection, False-Position, Newton - Raphson Methods,  Zeros of a polynomial using Birge – Vieta Method. 

(No. of Periods : 15)
SECTION B
3.Simultaneous Linear Equations : Solution of Simultaneous Linear Equations Using Gauss - Elimination, Gauss-Jordan and Gauss-Seidal Methods, Concept of Pivoting.  
4.Interpolation:  Lagrange,  Newton  forward,  Newton  Backward,  Divided  Difference, Newton forward difference, Newton Backward difference, Numerical  Integration: Trapezoidal, Simpson’s 1/3, Simpson’s 3/8, Weddle and Runga–    Kutta Methods: 2nd order & 4th order.

      (No. of Periods : 15) 

SECTION-C
5. Measures of Central Tendency:Peparing Frequency distribution table, Arithmetic mean, Geometric mean, Harmonic mean, Median and Mode.        6. Measures  of  Dispersion,  Skewness and Kurtosis,  Range :Mean   d…

ENVIRONMENT AND ROAD SAFETY EDUCATION

SEMESTER – IINote: 

The syllabus has 15 topics to be covered in 25-hour lectures in total, with 2 lectures in each topic from 2 to 11 and one each for the topics 1 and 12 to 15.

1. Environment Concept: Introduction, the concept of biosphere – lithosphere, hydrosphere, atmosphere; Natural resources – their need and types; Principles and scope of Ecology; concepts of the ecosystem, population, community, biotic interactions, biomes, ecological succession.

2. Atmosphere: Parts of atmosphere, components of air; pollution, pollutants, their sources, permissible limits, risks and possible control measures.

3. Hydrosphere: Types of aquatic systems; Major sources (including ground water) and uses of water, problems of the hydrosphere, fresh water shortage; pollution and pollutants of water, permissible limits, risks and possible control measures.

4. Lithosphere: Earth crust, soil – a life support system, its texture, types, components, pollution and pollutants, reasons of soil erosion and poss…