Upload
tsuchinoko123
View
219
Download
0
Embed Size (px)
Citation preview
7/29/2019 Tepl_rest of Prog
1/16
http://theonlinetutorials.com/category/software/language-software/c-programming-language-software/page/3
http://www.dailyfreecode.com/Code/data-types-variables-2660.aspx
/* Re: Write a Program Code In C to enter name and roll number of 5 students andsort the details as per roll number */
#include "stdio.h" "conio.h"type def struct student{char name[20];int roll;} s;main(){s s1[5],temp;clrscr();printf(" enter the name and roll of 5 students:");for(i=0;i
7/29/2019 Tepl_rest of Prog
2/16
};typedef struct person NAME;NAME stud[10], temp[10];
void main(){int no,i;
void sort(int N); /* Function declaration */
clrscr();fflush(stdin);
printf(Enter the number of students in the list\n);scanf(%d,&no);
for(i = 0; i < no; i++){printf(\nEnter the name of person %d : , i+1);fflush(stdin);gets(stud[i].name);
printf(Enter the roll number of %d : , i+1);scanf(%d,&stud[i].rno);
temp[i] = stud[i];}
printf(\n*****************************\n);printf ( Names before sorting \n);/* Print the list of names before sorting */for(i=0;i
7/29/2019 Tepl_rest of Prog
3/16
{temp = stud[i];stud[i] = stud[j];stud[j] = temp;}}}} /* end of sort() */
/*Enter the number of students in the list5
Enter the name of person 1 : RajashreeEnter the roll number of 1 : 123
Enter the name of person 2 : JohnEnter the roll number of 2 : 222
Enter the name of person 3 : PriyaEnter the roll number of 3 : 331
Enter the name of person 4 : AnandEnter the roll number of 4 : 411
Enter the name of person 5 : NirmalaEnter the roll number of 5 : 311
*****************************Names before sortingRajashree 123John 222Priya 331Anand 411Nirmala 311
*****************************
Names after sorting
*****************************Anand 411John 222Nirmala 311Priya 331Rajashree 123
*****************************-*/
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/*c-program-to-find-the-sum-of-two-matrices.html*/
#includevoid main(){int A[5][5], B[5][5], C[5][5], i, j, m, n;clrscr();
7/29/2019 Tepl_rest of Prog
4/16
printf(nnt ENTER A ORDER OF THE MATRICES M,N: );scanf(%d,%d, &m, &n);printf(nnt ENTER THE ELEMENTS OF THE FIRST MATRIX..:nn);for(i=1;i
7/29/2019 Tepl_rest of Prog
5/16
for(i=0;i
7/29/2019 Tepl_rest of Prog
6/16
if(d==0)printf("\nMATRIX IS NOT INVERSIBLE\n");elsecofact(a,k);}/******************FUNCTION TO FIND THE DETERMINANT OF THE MATRIX************************/
float detrm(float a[25][25],float k){float s=1,det=0,b[25][25];int i,j,m,n,c;if(k==1){return(a[0][0]);}else{det=0;for(c=0;c
7/29/2019 Tepl_rest of Prog
7/16
for(p=0;p
7/29/2019 Tepl_rest of Prog
8/16
for(j=0;j
7/29/2019 Tepl_rest of Prog
9/16
#include#includevoid main(){int i,j,n,t;int m[5][5];clrscr();printf("Enter Order of Matrix : ");scanf("%d",&n);printf("Enter Elements of Matrix :\n\n");for(i=0;i
7/29/2019 Tepl_rest of Prog
10/16
printf("Enter Order of Matrix : ");scanf("%d",&n);printf("Enter Elements of Matrix :\n\n");for(i=0;i
7/29/2019 Tepl_rest of Prog
11/16
}}for(i=0;i
7/29/2019 Tepl_rest of Prog
12/16
for(j=0;j
7/29/2019 Tepl_rest of Prog
13/16
{ printf("%d",&arr[i][j]);}}getch();}
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Write a c program to multiply two matrices
#include
int main(){int a[5][5],b[5][5],c[5][5];int i,j,k,sum=0,m,n,o,p;
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){
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
7/29/2019 Tepl_rest of Prog
14/16
sum=0;for(k=0;k
7/29/2019 Tepl_rest of Prog
15/16
Program to arrange the string in alphabetical order
#include "stdio.h"#include "conio.h"#include "string.h"void main(){
char str[10],temp;int i,j;clrscr();printf("\nEnter the string : ");scanf("%s",str);for(i=0;i
7/29/2019 Tepl_rest of Prog
16/16
Write a c program to sort a list of strings into alphabetical order?
#include#include#includeint main(){int i,j,n;char str[20][20],temp[20];puts("Enter the no. of string to be sorted");scanf("%d",&n);for(i=0;i