SlideShare ist ein Scribd-Unternehmen logo
1 von 34
BIRLA INSTITUTE OF TECHNOLOGY, MESRA 
DEPARTMENT OF REMOTE SNSING 
A 
PRACTICAL FILE 
ON 
“COMPUTER PROGRAMMING LAB” 
(TRS 2022) 
MASTER OF TECHNOLOGY 
(REMOTE SENSING) 
(20012-2014) 
SUBMITTED BY-SUMANT 
KR. DIWAKAR
C Practical File 
Program: 
Write a Program in C to convert Temperature from Fahrenheit 
to Celsius. 
Source Code: 
#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
float Fahrenheit, Celsius; 
clrscr(); 
printf("Enter Temperature in Fahrenheit: "); 
scanf("%f",&Fahrenheit); 
Celsius = 5.0/9.0 * (Fahrenheit-32); 
printf("nn Temperature in Fahrenheit = %.2f", 
Fahrenheit); 
printf("nn Temperature in Celsius = %.2f", 
Celsius); 
getch(); 
} 
Output: 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to check the number for Perfect Square. 
Source Code: 
#include <stdio.h> 
#include <conio.h> 
void main() 
{ 
int a, n; 
clrscr(); 
printf("Enter a number: "); 
scanf("%d", &n); 
for(a = 0; a <= n; a++) 
{ 
Sumant Diwakar 
if (n == a * a) 
{ 
printf("nntYES, Number is Perfect Square 
Number"); 
} 
} 
printf("nntNO, Not a Perfect square number"); 
getch(); 
} 
Output:
C Practical File 
Program: 
Write a Program in C to arrange numbers in Ascending and 
Descending Order. 
Source Code: 
#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int i,j,s,temp,a[20]; 
clrscr(); 
printf("Enter total elements: "); 
scanf("%d",&s); 
printf("nnEnter %d elements: ",s); 
for(i=0;i<s;i++) 
scanf("%d",&a[i]); 
for(i=1;i<s;i++){ 
temp=a[i]; 
j=i-1; 
while((temp<a[j])&&(j>=0)){ 
a[j+1]=a[j]; 
Sumant Diwakar 
j=j-1; 
} 
a[j+1]=temp; 
} 
printf("nAscending Ordern"); 
for(i=0;i<s;i++) 
printf("t %d",a[i]); 
printf("nDescending Ordern "); 
for(i=s-1;i>=0;i--) 
printf("t %d",a[i]); 
getch();
C Practical File 
} 
Output: 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to check the entered uppercase characters 
for vowel using switch statement. 
Source Code: 
#include <stdio.h> 
void main() 
{ 
char ch; 
clrscr(); 
printf("nInput a character in UPPERCASE only: "); 
scanf("%c", &ch); 
switch(ch) 
{ 
Sumant Diwakar 
case 'A': 
case 'E': 
case 'I': 
case 'O': 
case 'U': 
printf("nt%c is a vowel.n", ch); 
break; 
default: 
printf("nt%c Not in UPPERCASEn", ch); 
} 
getch(); 
} 
Output:
C Practical File 
Program: 
Write a Program in C to find the Factorial of a number. 
Source Code: 
#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int f=1,i,n; 
clrscr(); 
printf("Enter a numbern"); 
scanf("%d",&n); 
while(i<=n) 
{ 
Sumant Diwakar 
f=f * i; 
i=i+1; 
} 
printf("Factorial of %d is %d",n,f); 
getch(); 
} 
Output:
C Practical File 
Program: 
Write a Program in C to find the number and their sum between 
100 to 200 which are divisible by 7. 
Source Code: 
#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int n1,n2,sum=0; 
clrscr(); 
printf("nThe Number which are divisible by 7 
arenn"); 
for(n1=100; n1<200; n1++) 
{ 
Sumant Diwakar 
if(n1%7==0) 
{ 
printf("%dt",n1); 
sum=sum+n1; 
} 
} 
printf("nSum of numbers that are divisible by 7 is 
= %d",sum); 
getch(); 
} 
Output:
C Practical File 
Program: 
Write a Program in C to find the number is prime number or 
Composite number. 
Source Code: 
#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int n,i,np=0; //np is boolean operator (true/false) 
clrscr(); 
printf("n Enter a number :"); 
scanf("%d",&n); 
for(i=2;i<=(n-1);i++) 
{ 
Sumant Diwakar 
if(n%i==0) 
{ 
np=1; 
break; //come out of for loop 
} 
} 
if(np==1) // in if statement np=1 ,it confirms that 
number is composite. 
{ 
printf("nn%d is composite number.",n); 
} 
else 
{ 
printf("nn%d is a prime number.",n); 
} 
getch(); 
}
C Practical File 
Output: 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to find the Average of Five Numbers. 
Source Code: 
# include <stdio.h> 
#include <conio.h> 
void main() 
{ 
int first, second, third, fouth, fifth, sum=0, avg=0; 
clrscr(); 
printf("Enter First Number:"); 
scanf("%d", &first); 
printf("nnEnter Second Number:"); 
scanf("%d", &second); 
printf("nnEnter Third Number:"); 
scanf("%d", &third); 
printf("nnEnter Fourth Number:"); 
scanf("%d", &fourth); 
printf("nnEnter Fifth Number:"); 
scanf("%d", &fifth); 
sum = (first+second+third+fourth+fifth); 
avg = sum/5; 
printf("nntThe Average of Five Number is : %d",avg); 
getch(); 
} 
Output: 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to find the Biggest and smallest number 
from the given list of numbers. 
Source Code: 
#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int n,big,sml,i,totalNumber; 
clrscr(); 
printf("n How many number you will enter : "); 
scanf("%d",&totalNumber); 
for (i=0;i<totalNumber;i++) 
{ 
printf("n Enter number %d : ",i+1); 
scanf("%d",&n); 
if(i==0) 
{ 
big=sml=n; 
} 
if(big<n) big=n; 
if(sml>n) sml=n; 
} 
printf("nnBiggest number is: %d",big); 
printf("nnSmallest number is : %d",sml); 
getch(); 
} 
Sumant Diwakar
C Practical File 
Output: 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to find the sum of a digit of a number. 
Source Code: 
#include<stdio.h> 
void main() 
{ 
int num,sum=0,r; 
printf("Enter a number: "); 
scanf("%d",&num); 
while(num){ 
r=num%10; 
num=num/10; 
sum=sum+r; 
} 
printf("Sum of digits of number: %d",sum); 
getch(); 
} 
Output: 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to enter three digit numbers and find the 
sum of the digits. 
Source Code: 
#include<stdio.h> 
void main() 
{ 
int num,sum=0,r; 
clrscr(); 
printf("Enter a #-digit number[100-999]: "); 
scanf("%d",&num); 
if(num>999 && num<100) 
printf("nnSorry!, Number Out of Range "); 
else 
{ 
while(num) 
{ 
Sumant Diwakar 
r=num%10; 
num=num/10; 
sum=sum+r; 
} 
printf("nSum of digits of number: %d",sum); 
} 
getch(); 
} 
Output:
C Practical File 
Program: 
Write a Program in C to generate the Fibonacci Series. 
(0, 1, 1, 2, 3, 5, 8
) 
Source Code: 
#include <stdio.h> 
void main() 
{ 
int n, first = 0, second = 1, next, c; 
clrscr(); 
printf("Enter the number of terms:"); 
scanf("%d",&n); 
printf("nnFirst %d terms of Fibonacci series are :- 
nn",n); 
for ( c = 0 ; c < n ; c++ ) 
{ 
Sumant Diwakar 
if ( c <= 1 ) 
next = c; 
else 
{ 
next = first + second; 
first = second; 
second = next; 
} 
printf("%d ",next); 
} 
getch(); 
}
C Practical File 
Output: 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to display the following patterns using 
loop. 
Source Code: 
1) 
#include <stdio.h> 
#include <conio.h> 
void main() 
{ 
int i,j,limit; 
clrscr(); 
printf("nEnter Limit:"); 
scanf("%d",&limit); 
for(i=0; i<limit; i++) 
{ 
Sumant Diwakar 
for(j=0; j<=i; j++) 
{ 
printf(" * "); 
} 
printf("n"); 
} 
getch(); 
} 
2) * 
* * 
* * * 
* * * * 
* * * * * 
1) * 
* * 
* * * 
* * * * 
* * * * *
C Practical File 
Output: 
2) 
#include <stdio.h> 
#include <conio.h> 
void main() 
{ 
int i,j,k,limit; 
clrscr(); 
printf("nEnter Limit: "); 
scanf("%d",&limit); 
for(i=0; i<limit; i++) 
for(i=1; i<=limit; i++) 
{ 
Sumant Diwakar 
for(j=limit; j>=i; j--) 
{ 
printf(" "); 
} 
for(k=1; k<=i; k++) 
{ 
printf("*"); 
} 
printf("n"); 
} 
getch(); 
}
C Practical File 
Output: 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to find factorial of given number using 
recursive function. 
Source Code: 
#include<stdio.h> 
main() 
{ 
int a,b; 
clrscr(); 
printf("Enter the value for A and Bn"); 
scanf("%d %d",&a,&b); 
printf("nBefore Swaping:nntA= %d, B=%d",a,b); 
swap(a,b); 
getch(); 
} 
swap(int x,int y) 
{ 
int temp; 
temp=x; 
x=y; 
y=temp; 
printf("nnAfter Swaping:nntA=%d, B=%d",x,y); 
} 
Output: 
Sumant Diwakar
C Practical File 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to find factorial of given number using 
recursive function. 
Source Code: 
#include<stdio.h> 
main() 
{ 
int a, fact; 
printf("nEnter any number: "); 
scanf ("%d", &a); 
fact=rec (a); 
printf("nFactorial Value = %d", fact); 
} 
rec (int x) 
{ 
int f; 
Sumant Diwakar 
if (x==1) 
return (1); 
else 
f=x*rec(x-1); 
return (f); 
}
C Practical File 
Output: 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to print Identity Matrix. 
Source Code: 
#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int a[20][20],i,j,row,col; 
clrscr(); 
printf("Enter Square Matrix Range:"); 
scanf("%d",&row); 
col=row; 
for(i=0;i<row;i++) 
{ 
Sumant Diwakar 
for(j=0;j<col;j++) 
{ 
if(i==j) 
{ 
a[i][j]=1; 
} 
else 
{ 
printf("Enter matrix value:"); 
scanf("%d", &a[i][j]); 
} 
} 
} 
printf("nn identity matrix n"); 
for(i=0;i<row;i++) 
{ 
for(j=0;j<col;j++) 
{ 
printf("t%d", a[i][j]); 
} 
printf("n"); 
} 
getch(); 
}
C Practical File 
Output: 
Program: 
Write a Program in C to find the addition of two 3 x 3 matrices. 
Sumant Diwakar
C Practical File 
Source Code: 
#include<stdio.h> 
Void main() 
{ 
int a[3][3],b[3][3],c[3][3],i,j; 
clrscr(); 
printf("Enter the First matrix->"); 
for(i=0;i<3;i++) 
Sumant Diwakar 
for(j=0;j<3;j++) 
scanf("%d",&a[i][j]); 
printf("nEnter the Second matrix->"); 
for(i=0;i<3;i++) 
for(j=0;j<3;j++) 
scanf("%d",&b[i][j]); 
printf("nThe First matrix isn"); 
for(i=0;i<3;i++) 
{ 
printf("n"); 
for(j=0;j<3;j++) 
printf("%dt",a[i][j]); 
} 
printf("nThe Second matrix isn"); 
for(i=0;i<3;i++) 
{ 
printf("n"); 
for(j=0;j<3;j++) 
printf("%dt",b[i][j]); 
} 
for(i=0;i<3;i++) 
for(j=0;j<3;j++) 
c[i][j]=a[i][j]+b[i][j]; 
printf("nThe Addition of two matrix isn"); 
for(i=0;i<3;i++){ 
printf("n"); 
for(j=0;j<3;j++) 
printf("%dt",c[i][j]); 
}
C Practical File 
getch(); 
} 
Output: 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to find the multiplication of two matrices. 
Source Code: 
#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int a[5][5],b[5][5],c[5][5],i,j,k,sum=0,m,n,o,p; 
clrscr(); 
printf("nEnter the row and column of first matrix"); 
scanf("%d %d",&m,&n); 
printf("nEnter the row and column of second matrix"); 
scanf("%d %d",&o,&p); 
if(n!=o) 
{ 
Sumant Diwakar 
printf("Matrix mutiplication is not possible"); 
printf("nColumn of first matrix must be same 
as row of second matrix"); 
} 
else 
{ 
printf("nEnter the First matrix->"); 
for(i=0;i<m;i++) 
for(j=0;j<n;j++) 
scanf("%d",&a[i][j]); 
printf("nEnter the Second matrix->"); 
for(i=0;i<o;i++) 
for(j=0;j<p;j++) 
scanf("%d",&b[i][j]); 
printf("nThe First matrix isn"); 
for(i=0;i<m;i++){ 
printf("n"); 
for(j=0;j<n;j++){ 
printf("%dt",a[i][j]); 
} 
} 
printf("nThe Second matrix isn");
C Practical File 
for(i=0;i<o;i++){ 
printf("n"); 
for(j=0;j<p;j++){ 
printf("%dt",b[i][j]); 
} 
} 
for(i=0;i<m;i++) 
for(j=0;j<p;j++) 
c[i][j]=0; 
for(i=0;i<m;i++){ //row of first matrix 
for(j=0;j<p;j++){ //column of second matrix 
sum=0; 
for(k=0;k<n;k++) 
Sumant Diwakar 
sum=sum+a[i][k]*b[k][j]; 
c[i][j]=sum; 
} 
} 
} 
printf("nThe multiplication of two matrix isn"); 
for(i=0;i<m;i++){ 
printf("n"); 
for(j=0;j<p;j++){ 
printf("%dt",c[i][j]); 
} 
} 
getch(); 
}
C Practical File 
Output: 
Sumant Diwakar
C Practical File 
Program: 
Write a Program in C to find the length of a string and count the 
number of vowel in it. 
Source Code: 
#include <stdio.h> 
#include <string.h> 
void main() 
{ 
Sumant Diwakar 
char str[50]; 
int vowels=0; 
int consonants=0; 
int space=0; 
int len,i; 
printf("enter the string  n n"); 
gets(str); 
len=strlen(str); 
for(i=0; i< len ;i++) 
{ 
if(str[i]=='a'||str[i]=='A'||str[i]=='i'||str[i]=='I'||str[i] 
=='E'||str[i]=='e'||str[i]=='O'||str[i]=='o'||str[i]=='U'||st 
r[i]=='u') 
vowels++; 
else 
{ 
consonants++; 
} 
if(str[i]==' ') 
{ 
space ++; 
} 
}
C Practical File 
printf("Number of Vowels %d and Number of Consonants 
%d",vowels,consonants); 
Sumant Diwakar 
printf(" n Number of Spaces :% d",space); 
getch(); 
} 
Output:
C Practical File 
Program: 
Write a Program in C to check the given string is Palindrome or 
not . 
Source Code: 
# include <stdio.h> 
# include <conio.h> 
# include <string.h> 
void main() 
{ 
char str[20], rev[20] ; 
int i, j, l ; 
clrscr() ; 
printf("Enter a string : ") ; 
scanf("%s", str) ; 
for(l = 0 ; str[l] != '0' ; l++) ; 
for(i = l - 1, j = 0 ; i >= 0 ; i--, j++) 
rev[j] = str[i] ; 
rev[j] = '0' ; 
if(strcmp(str, rev) == 0) 
printf("nThe given string is a palindrome") ; 
else 
printf("nThe given string is not a palindrome") ; 
getch() ; 
} 
Output: 
Sumant Diwakar

Weitere Àhnliche Inhalte

Was ist angesagt?

Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by ExampleOlve Maudal
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C v_jk
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File Rahul Chugh
 
Call by value
Call by valueCall by value
Call by valueDharani G
 
C if else
C if elseC if else
C if elseRitwik Das
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
 
Pointers and call by value, reference, address in C
Pointers and call by value, reference, address in CPointers and call by value, reference, address in C
Pointers and call by value, reference, address in CSyed Mustafa
 
C fundamental
C fundamentalC fundamental
C fundamentalSelvam Edwin
 
Functions in c language
Functions in c language Functions in c language
Functions in c language tanmaymodi4
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++Shyam Gupta
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programmingTejaswiB4
 
PPS Notes Unit 5.pdf
PPS Notes Unit 5.pdfPPS Notes Unit 5.pdf
PPS Notes Unit 5.pdfSreedhar Chowdam
 
Object Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical FileObject Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical FileHarjinder Singh
 
Stack using Array
Stack using ArrayStack using Array
Stack using ArraySayantan Sur
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)Make Mannan
 
Deep C Programming
Deep C ProgrammingDeep C Programming
Deep C ProgrammingWang Hao Lee
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C BUBT
 

Was ist angesagt? (20)

Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by Example
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Call by value
Call by valueCall by value
Call by value
 
C if else
C if elseC if else
C if else
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Pointers and call by value, reference, address in C
Pointers and call by value, reference, address in CPointers and call by value, reference, address in C
Pointers and call by value, reference, address in C
 
C fundamental
C fundamentalC fundamental
C fundamental
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Ansi c
Ansi cAnsi c
Ansi c
 
PPS Notes Unit 5.pdf
PPS Notes Unit 5.pdfPPS Notes Unit 5.pdf
PPS Notes Unit 5.pdf
 
Object Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical FileObject Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical File
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Control statements
Control statementsControl statements
Control statements
 
Stack using Array
Stack using ArrayStack using Array
Stack using Array
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
 
Deep C Programming
Deep C ProgrammingDeep C Programming
Deep C Programming
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C
 

Andere mochten auch

Principle of photogrammetry
Principle of photogrammetryPrinciple of photogrammetry
Principle of photogrammetrySumant Diwakar
 
Optical remote sensing
Optical remote sensingOptical remote sensing
Optical remote sensingSumant Diwakar
 
Solar irradiation & spectral signature
Solar irradiation & spectral signatureSolar irradiation & spectral signature
Solar irradiation & spectral signatureSumant Diwakar
 
Interaction of EMR with atmosphere and earth surface
Interaction of EMR with atmosphere and earth surfaceInteraction of EMR with atmosphere and earth surface
Interaction of EMR with atmosphere and earth surfaceSumant Diwakar
 
Hydrologic Assessment in a Middle Narmada Basin, India using SWAT Model
Hydrologic Assessment in a Middle Narmada Basin, India using SWAT ModelHydrologic Assessment in a Middle Narmada Basin, India using SWAT Model
Hydrologic Assessment in a Middle Narmada Basin, India using SWAT ModelSumant Diwakar
 
History of remote sensing
History of remote sensingHistory of remote sensing
History of remote sensingSumant Diwakar
 

Andere mochten auch (8)

Principle of photogrammetry
Principle of photogrammetryPrinciple of photogrammetry
Principle of photogrammetry
 
Optical remote sensing
Optical remote sensingOptical remote sensing
Optical remote sensing
 
Solar irradiation & spectral signature
Solar irradiation & spectral signatureSolar irradiation & spectral signature
Solar irradiation & spectral signature
 
Soil moisture
Soil moistureSoil moisture
Soil moisture
 
Interaction of EMR with atmosphere and earth surface
Interaction of EMR with atmosphere and earth surfaceInteraction of EMR with atmosphere and earth surface
Interaction of EMR with atmosphere and earth surface
 
C Programming
C ProgrammingC Programming
C Programming
 
Hydrologic Assessment in a Middle Narmada Basin, India using SWAT Model
Hydrologic Assessment in a Middle Narmada Basin, India using SWAT ModelHydrologic Assessment in a Middle Narmada Basin, India using SWAT Model
Hydrologic Assessment in a Middle Narmada Basin, India using SWAT Model
 
History of remote sensing
History of remote sensingHistory of remote sensing
History of remote sensing
 

Ähnlich wie C Programming

'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)Ashishchinu
 
C basics
C basicsC basics
C basicsMSc CST
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programsPrasadu Peddi
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
SaraPIC
SaraPICSaraPIC
SaraPICSara Sahu
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using cArghodeepPaul
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentalsZaibi Gondal
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkarsandeep kumbhkar
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solutionyogini sharma
 
C Programming lab
C Programming labC Programming lab
C Programming labVikram Nandini
 
Core programming in c
Core programming in cCore programming in c
Core programming in cRahul Pandit
 

Ähnlich wie C Programming (20)

C lab
C labC lab
C lab
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
C basics
C basicsC basics
C basics
 
C programs
C programsC programs
C programs
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
C file
C fileC file
C file
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
C programms
C programmsC programms
C programms
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
 
Hargun
HargunHargun
Hargun
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
C
CC
C
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 

Mehr von Sumant Diwakar

REMOTE SENSING & GIS APPLICATIONS IN WATERSHED MANAGEMENT
REMOTE SENSING & GIS APPLICATIONS IN WATERSHED MANAGEMENT REMOTE SENSING & GIS APPLICATIONS IN WATERSHED MANAGEMENT
REMOTE SENSING & GIS APPLICATIONS IN WATERSHED MANAGEMENT Sumant Diwakar
 
Relation between Ground-based Soil Moisture and Satellite Image-based NDVI
Relation between Ground-based Soil Moisture and Satellite Image-based NDVIRelation between Ground-based Soil Moisture and Satellite Image-based NDVI
Relation between Ground-based Soil Moisture and Satellite Image-based NDVISumant Diwakar
 
Electromagnetic radiation
Electromagnetic radiationElectromagnetic radiation
Electromagnetic radiationSumant Diwakar
 
Differential gps (dgps) 09 04-12
Differential gps (dgps) 09 04-12Differential gps (dgps) 09 04-12
Differential gps (dgps) 09 04-12Sumant Diwakar
 
Digital terrain model
Digital terrain modelDigital terrain model
Digital terrain modelSumant Diwakar
 
Digital orthophoto
Digital orthophotoDigital orthophoto
Digital orthophotoSumant Diwakar
 
Automatic digital terrain modelling
Automatic digital terrain modellingAutomatic digital terrain modelling
Automatic digital terrain modellingSumant Diwakar
 
Aerial photography abraham thomas
Aerial photography abraham thomasAerial photography abraham thomas
Aerial photography abraham thomasSumant Diwakar
 
Aerial photographs and their interpretation
Aerial photographs and their interpretationAerial photographs and their interpretation
Aerial photographs and their interpretationSumant Diwakar
 
Wide field sensor
Wide field sensorWide field sensor
Wide field sensorSumant Diwakar
 
Indian remote sensing
Indian remote sensingIndian remote sensing
Indian remote sensingSumant Diwakar
 

Mehr von Sumant Diwakar (20)

REMOTE SENSING & GIS APPLICATIONS IN WATERSHED MANAGEMENT
REMOTE SENSING & GIS APPLICATIONS IN WATERSHED MANAGEMENT REMOTE SENSING & GIS APPLICATIONS IN WATERSHED MANAGEMENT
REMOTE SENSING & GIS APPLICATIONS IN WATERSHED MANAGEMENT
 
Relation between Ground-based Soil Moisture and Satellite Image-based NDVI
Relation between Ground-based Soil Moisture and Satellite Image-based NDVIRelation between Ground-based Soil Moisture and Satellite Image-based NDVI
Relation between Ground-based Soil Moisture and Satellite Image-based NDVI
 
Electromagnetic radiation
Electromagnetic radiationElectromagnetic radiation
Electromagnetic radiation
 
Map projection
Map projectionMap projection
Map projection
 
Differential gps (dgps) 09 04-12
Differential gps (dgps) 09 04-12Differential gps (dgps) 09 04-12
Differential gps (dgps) 09 04-12
 
Digital terrain model
Digital terrain modelDigital terrain model
Digital terrain model
 
Digital orthophoto
Digital orthophotoDigital orthophoto
Digital orthophoto
 
Automatic digital terrain modelling
Automatic digital terrain modellingAutomatic digital terrain modelling
Automatic digital terrain modelling
 
Aerial photography abraham thomas
Aerial photography abraham thomasAerial photography abraham thomas
Aerial photography abraham thomas
 
Aerial photographs and their interpretation
Aerial photographs and their interpretationAerial photographs and their interpretation
Aerial photographs and their interpretation
 
Wide field sensor
Wide field sensorWide field sensor
Wide field sensor
 
Thematic mapper
Thematic mapperThematic mapper
Thematic mapper
 
MSS
MSSMSS
MSS
 
MODIS
MODISMODIS
MODIS
 
LISS
LISSLISS
LISS
 
SPOT
SPOTSPOT
SPOT
 
RADARSAT
RADARSATRADARSAT
RADARSAT
 
LANDSAT
LANDSATLANDSAT
LANDSAT
 
Indian remote sensing
Indian remote sensingIndian remote sensing
Indian remote sensing
 
Ikonos
IkonosIkonos
Ikonos
 

KĂŒrzlich hochgeladen

Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïžcall girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïžDelhi Call girls
 
(Genuine) Escort Service Lucknow | Starting â‚č,5K To @25k with A/C đŸ§‘đŸœâ€â€ïžâ€đŸ§‘đŸ» 89...
(Genuine) Escort Service Lucknow | Starting â‚č,5K To @25k with A/C đŸ§‘đŸœâ€â€ïžâ€đŸ§‘đŸ» 89...(Genuine) Escort Service Lucknow | Starting â‚č,5K To @25k with A/C đŸ§‘đŸœâ€â€ïžâ€đŸ§‘đŸ» 89...
(Genuine) Escort Service Lucknow | Starting â‚č,5K To @25k with A/C đŸ§‘đŸœâ€â€ïžâ€đŸ§‘đŸ» 89...gurkirankumar98700
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
CALL ON ➄8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂
CALL ON ➄8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂CALL ON ➄8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂
CALL ON ➄8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂anilsa9823
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

KĂŒrzlich hochgeladen (20)

Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Call Girls In Mukherjee Nagar đŸ“± 9999965857 đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar đŸ“±  9999965857  đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar đŸ“±  9999965857  đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar đŸ“± 9999965857 đŸ€© Delhi đŸ«Š HOT AND SEXY VVIP 🍎 SE...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïžcall girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
call girls in Vaishali (Ghaziabad) 🔝 >àŒ’8448380779 🔝 genuine Escort Service đŸ”âœ”ïžâœ”ïž
 
(Genuine) Escort Service Lucknow | Starting â‚č,5K To @25k with A/C đŸ§‘đŸœâ€â€ïžâ€đŸ§‘đŸ» 89...
(Genuine) Escort Service Lucknow | Starting â‚č,5K To @25k with A/C đŸ§‘đŸœâ€â€ïžâ€đŸ§‘đŸ» 89...(Genuine) Escort Service Lucknow | Starting â‚č,5K To @25k with A/C đŸ§‘đŸœâ€â€ïžâ€đŸ§‘đŸ» 89...
(Genuine) Escort Service Lucknow | Starting â‚č,5K To @25k with A/C đŸ§‘đŸœâ€â€ïžâ€đŸ§‘đŸ» 89...
 
Vip Call Girls Noida âžĄïž Delhi âžĄïž 9999965857 No Advance 24HRS Live
Vip Call Girls Noida âžĄïž Delhi âžĄïž 9999965857 No Advance 24HRS LiveVip Call Girls Noida âžĄïž Delhi âžĄïž 9999965857 No Advance 24HRS Live
Vip Call Girls Noida âžĄïž Delhi âžĄïž 9999965857 No Advance 24HRS Live
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
CALL ON ➄8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂
CALL ON ➄8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂CALL ON ➄8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂
CALL ON ➄8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

C Programming

  • 1. BIRLA INSTITUTE OF TECHNOLOGY, MESRA DEPARTMENT OF REMOTE SNSING A PRACTICAL FILE ON “COMPUTER PROGRAMMING LAB” (TRS 2022) MASTER OF TECHNOLOGY (REMOTE SENSING) (20012-2014) SUBMITTED BY-SUMANT KR. DIWAKAR
  • 2. C Practical File Program: Write a Program in C to convert Temperature from Fahrenheit to Celsius. Source Code: #include<stdio.h> #include<conio.h> void main() { float Fahrenheit, Celsius; clrscr(); printf("Enter Temperature in Fahrenheit: "); scanf("%f",&Fahrenheit); Celsius = 5.0/9.0 * (Fahrenheit-32); printf("nn Temperature in Fahrenheit = %.2f", Fahrenheit); printf("nn Temperature in Celsius = %.2f", Celsius); getch(); } Output: Sumant Diwakar
  • 3. C Practical File Program: Write a Program in C to check the number for Perfect Square. Source Code: #include <stdio.h> #include <conio.h> void main() { int a, n; clrscr(); printf("Enter a number: "); scanf("%d", &n); for(a = 0; a <= n; a++) { Sumant Diwakar if (n == a * a) { printf("nntYES, Number is Perfect Square Number"); } } printf("nntNO, Not a Perfect square number"); getch(); } Output:
  • 4. C Practical File Program: Write a Program in C to arrange numbers in Ascending and Descending Order. Source Code: #include<stdio.h> #include<conio.h> void main() { int i,j,s,temp,a[20]; clrscr(); printf("Enter total elements: "); scanf("%d",&s); printf("nnEnter %d elements: ",s); for(i=0;i<s;i++) scanf("%d",&a[i]); for(i=1;i<s;i++){ temp=a[i]; j=i-1; while((temp<a[j])&&(j>=0)){ a[j+1]=a[j]; Sumant Diwakar j=j-1; } a[j+1]=temp; } printf("nAscending Ordern"); for(i=0;i<s;i++) printf("t %d",a[i]); printf("nDescending Ordern "); for(i=s-1;i>=0;i--) printf("t %d",a[i]); getch();
  • 5. C Practical File } Output: Sumant Diwakar
  • 6. C Practical File Program: Write a Program in C to check the entered uppercase characters for vowel using switch statement. Source Code: #include <stdio.h> void main() { char ch; clrscr(); printf("nInput a character in UPPERCASE only: "); scanf("%c", &ch); switch(ch) { Sumant Diwakar case 'A': case 'E': case 'I': case 'O': case 'U': printf("nt%c is a vowel.n", ch); break; default: printf("nt%c Not in UPPERCASEn", ch); } getch(); } Output:
  • 7. C Practical File Program: Write a Program in C to find the Factorial of a number. Source Code: #include<stdio.h> #include<conio.h> void main() { int f=1,i,n; clrscr(); printf("Enter a numbern"); scanf("%d",&n); while(i<=n) { Sumant Diwakar f=f * i; i=i+1; } printf("Factorial of %d is %d",n,f); getch(); } Output:
  • 8. C Practical File Program: Write a Program in C to find the number and their sum between 100 to 200 which are divisible by 7. Source Code: #include<stdio.h> #include<conio.h> void main() { int n1,n2,sum=0; clrscr(); printf("nThe Number which are divisible by 7 arenn"); for(n1=100; n1<200; n1++) { Sumant Diwakar if(n1%7==0) { printf("%dt",n1); sum=sum+n1; } } printf("nSum of numbers that are divisible by 7 is = %d",sum); getch(); } Output:
  • 9. C Practical File Program: Write a Program in C to find the number is prime number or Composite number. Source Code: #include<stdio.h> #include<conio.h> void main() { int n,i,np=0; //np is boolean operator (true/false) clrscr(); printf("n Enter a number :"); scanf("%d",&n); for(i=2;i<=(n-1);i++) { Sumant Diwakar if(n%i==0) { np=1; break; //come out of for loop } } if(np==1) // in if statement np=1 ,it confirms that number is composite. { printf("nn%d is composite number.",n); } else { printf("nn%d is a prime number.",n); } getch(); }
  • 10. C Practical File Output: Sumant Diwakar
  • 11. C Practical File Program: Write a Program in C to find the Average of Five Numbers. Source Code: # include <stdio.h> #include <conio.h> void main() { int first, second, third, fouth, fifth, sum=0, avg=0; clrscr(); printf("Enter First Number:"); scanf("%d", &first); printf("nnEnter Second Number:"); scanf("%d", &second); printf("nnEnter Third Number:"); scanf("%d", &third); printf("nnEnter Fourth Number:"); scanf("%d", &fourth); printf("nnEnter Fifth Number:"); scanf("%d", &fifth); sum = (first+second+third+fourth+fifth); avg = sum/5; printf("nntThe Average of Five Number is : %d",avg); getch(); } Output: Sumant Diwakar
  • 12. C Practical File Program: Write a Program in C to find the Biggest and smallest number from the given list of numbers. Source Code: #include<stdio.h> #include<conio.h> void main() { int n,big,sml,i,totalNumber; clrscr(); printf("n How many number you will enter : "); scanf("%d",&totalNumber); for (i=0;i<totalNumber;i++) { printf("n Enter number %d : ",i+1); scanf("%d",&n); if(i==0) { big=sml=n; } if(big<n) big=n; if(sml>n) sml=n; } printf("nnBiggest number is: %d",big); printf("nnSmallest number is : %d",sml); getch(); } Sumant Diwakar
  • 13. C Practical File Output: Sumant Diwakar
  • 14. C Practical File Program: Write a Program in C to find the sum of a digit of a number. Source Code: #include<stdio.h> void main() { int num,sum=0,r; printf("Enter a number: "); scanf("%d",&num); while(num){ r=num%10; num=num/10; sum=sum+r; } printf("Sum of digits of number: %d",sum); getch(); } Output: Sumant Diwakar
  • 15. C Practical File Program: Write a Program in C to enter three digit numbers and find the sum of the digits. Source Code: #include<stdio.h> void main() { int num,sum=0,r; clrscr(); printf("Enter a #-digit number[100-999]: "); scanf("%d",&num); if(num>999 && num<100) printf("nnSorry!, Number Out of Range "); else { while(num) { Sumant Diwakar r=num%10; num=num/10; sum=sum+r; } printf("nSum of digits of number: %d",sum); } getch(); } Output:
  • 16. C Practical File Program: Write a Program in C to generate the Fibonacci Series. (0, 1, 1, 2, 3, 5, 8
) Source Code: #include <stdio.h> void main() { int n, first = 0, second = 1, next, c; clrscr(); printf("Enter the number of terms:"); scanf("%d",&n); printf("nnFirst %d terms of Fibonacci series are :- nn",n); for ( c = 0 ; c < n ; c++ ) { Sumant Diwakar if ( c <= 1 ) next = c; else { next = first + second; first = second; second = next; } printf("%d ",next); } getch(); }
  • 17. C Practical File Output: Sumant Diwakar
  • 18. C Practical File Program: Write a Program in C to display the following patterns using loop. Source Code: 1) #include <stdio.h> #include <conio.h> void main() { int i,j,limit; clrscr(); printf("nEnter Limit:"); scanf("%d",&limit); for(i=0; i<limit; i++) { Sumant Diwakar for(j=0; j<=i; j++) { printf(" * "); } printf("n"); } getch(); } 2) * * * * * * * * * * * * * * * 1) * * * * * * * * * * * * * * *
  • 19. C Practical File Output: 2) #include <stdio.h> #include <conio.h> void main() { int i,j,k,limit; clrscr(); printf("nEnter Limit: "); scanf("%d",&limit); for(i=0; i<limit; i++) for(i=1; i<=limit; i++) { Sumant Diwakar for(j=limit; j>=i; j--) { printf(" "); } for(k=1; k<=i; k++) { printf("*"); } printf("n"); } getch(); }
  • 20. C Practical File Output: Sumant Diwakar
  • 21. C Practical File Program: Write a Program in C to find factorial of given number using recursive function. Source Code: #include<stdio.h> main() { int a,b; clrscr(); printf("Enter the value for A and Bn"); scanf("%d %d",&a,&b); printf("nBefore Swaping:nntA= %d, B=%d",a,b); swap(a,b); getch(); } swap(int x,int y) { int temp; temp=x; x=y; y=temp; printf("nnAfter Swaping:nntA=%d, B=%d",x,y); } Output: Sumant Diwakar
  • 22. C Practical File Sumant Diwakar
  • 23. C Practical File Program: Write a Program in C to find factorial of given number using recursive function. Source Code: #include<stdio.h> main() { int a, fact; printf("nEnter any number: "); scanf ("%d", &a); fact=rec (a); printf("nFactorial Value = %d", fact); } rec (int x) { int f; Sumant Diwakar if (x==1) return (1); else f=x*rec(x-1); return (f); }
  • 24. C Practical File Output: Sumant Diwakar
  • 25. C Practical File Program: Write a Program in C to print Identity Matrix. Source Code: #include<stdio.h> #include<conio.h> void main() { int a[20][20],i,j,row,col; clrscr(); printf("Enter Square Matrix Range:"); scanf("%d",&row); col=row; for(i=0;i<row;i++) { Sumant Diwakar for(j=0;j<col;j++) { if(i==j) { a[i][j]=1; } else { printf("Enter matrix value:"); scanf("%d", &a[i][j]); } } } printf("nn identity matrix n"); for(i=0;i<row;i++) { for(j=0;j<col;j++) { printf("t%d", a[i][j]); } printf("n"); } getch(); }
  • 26. C Practical File Output: Program: Write a Program in C to find the addition of two 3 x 3 matrices. Sumant Diwakar
  • 27. C Practical File Source Code: #include<stdio.h> Void main() { int a[3][3],b[3][3],c[3][3],i,j; clrscr(); printf("Enter the First matrix->"); for(i=0;i<3;i++) Sumant Diwakar for(j=0;j<3;j++) scanf("%d",&a[i][j]); printf("nEnter the Second matrix->"); for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%d",&b[i][j]); printf("nThe First matrix isn"); for(i=0;i<3;i++) { printf("n"); for(j=0;j<3;j++) printf("%dt",a[i][j]); } printf("nThe Second matrix isn"); for(i=0;i<3;i++) { printf("n"); for(j=0;j<3;j++) printf("%dt",b[i][j]); } for(i=0;i<3;i++) for(j=0;j<3;j++) c[i][j]=a[i][j]+b[i][j]; printf("nThe Addition of two matrix isn"); for(i=0;i<3;i++){ printf("n"); for(j=0;j<3;j++) printf("%dt",c[i][j]); }
  • 28. C Practical File getch(); } Output: Sumant Diwakar
  • 29. C Practical File Program: Write a Program in C to find the multiplication of two matrices. Source Code: #include<stdio.h> #include<conio.h> void main() { int a[5][5],b[5][5],c[5][5],i,j,k,sum=0,m,n,o,p; clrscr(); printf("nEnter the row and column of first matrix"); scanf("%d %d",&m,&n); printf("nEnter the row and column of second matrix"); scanf("%d %d",&o,&p); if(n!=o) { Sumant Diwakar printf("Matrix mutiplication is not possible"); printf("nColumn of first matrix must be same as row of second matrix"); } else { printf("nEnter the First matrix->"); for(i=0;i<m;i++) for(j=0;j<n;j++) scanf("%d",&a[i][j]); printf("nEnter the Second matrix->"); for(i=0;i<o;i++) for(j=0;j<p;j++) scanf("%d",&b[i][j]); printf("nThe First matrix isn"); for(i=0;i<m;i++){ printf("n"); for(j=0;j<n;j++){ printf("%dt",a[i][j]); } } printf("nThe Second matrix isn");
  • 30. C Practical File for(i=0;i<o;i++){ printf("n"); for(j=0;j<p;j++){ printf("%dt",b[i][j]); } } for(i=0;i<m;i++) for(j=0;j<p;j++) c[i][j]=0; for(i=0;i<m;i++){ //row of first matrix for(j=0;j<p;j++){ //column of second matrix sum=0; for(k=0;k<n;k++) Sumant Diwakar sum=sum+a[i][k]*b[k][j]; c[i][j]=sum; } } } printf("nThe multiplication of two matrix isn"); for(i=0;i<m;i++){ printf("n"); for(j=0;j<p;j++){ printf("%dt",c[i][j]); } } getch(); }
  • 31. C Practical File Output: Sumant Diwakar
  • 32. C Practical File Program: Write a Program in C to find the length of a string and count the number of vowel in it. Source Code: #include <stdio.h> #include <string.h> void main() { Sumant Diwakar char str[50]; int vowels=0; int consonants=0; int space=0; int len,i; printf("enter the string n n"); gets(str); len=strlen(str); for(i=0; i< len ;i++) { if(str[i]=='a'||str[i]=='A'||str[i]=='i'||str[i]=='I'||str[i] =='E'||str[i]=='e'||str[i]=='O'||str[i]=='o'||str[i]=='U'||st r[i]=='u') vowels++; else { consonants++; } if(str[i]==' ') { space ++; } }
  • 33. C Practical File printf("Number of Vowels %d and Number of Consonants %d",vowels,consonants); Sumant Diwakar printf(" n Number of Spaces :% d",space); getch(); } Output:
  • 34. C Practical File Program: Write a Program in C to check the given string is Palindrome or not . Source Code: # include <stdio.h> # include <conio.h> # include <string.h> void main() { char str[20], rev[20] ; int i, j, l ; clrscr() ; printf("Enter a string : ") ; scanf("%s", str) ; for(l = 0 ; str[l] != '0' ; l++) ; for(i = l - 1, j = 0 ; i >= 0 ; i--, j++) rev[j] = str[i] ; rev[j] = '0' ; if(strcmp(str, rev) == 0) printf("nThe given string is a palindrome") ; else printf("nThe given string is not a palindrome") ; getch() ; } Output: Sumant Diwakar