Beruflich Dokumente
Kultur Dokumente
SOME C
PROGRAMS
FOR
PRACTICE
If the marks of a student in five different subjects entered by the keyboard so find out
the average marks and percentage of obtained marks of student assume the max. marks of
each subject is 100.
/* A program of print the marksheet and show the percentage of obtained marks*/
/* Note : I'm using only 5 subjects and each subjects have max : 100 and min 40 marks*/
#include<stdio.h>
void main()
{
int mca101,mca102,mca103,mca104,mca105,total;
float per;
clrscr();
printf("Please enter the marks of MCA101 : ");
scanf("%d",&mca101);
printf("Please enter the marks of MCA102 : ");
scanf("%d",&mca102);
printf("Please enter the marks of MCA103 : ");
scanf("%d",&mca103);
printf("Please enter the marks of MCA104 : ");
scanf("%d",&mca104);
printf("Please enter the marks of MCA105 : ");
scanf("%d",&mca105);
total=mca101+mca102+mca103+mca104+mca105;
per=total/5;
printf("\n ---------------------------------------------------------------");
printf("\n * MARKSHEET OF MCA -I SEM *" );
printf("\n ---------------------------------------------------------------");
printf("\n SUBJECT SUBJECT CODE MIN MAX MARKS OBTAINED");
printf("\n ---------------------------------------------------------------");
printf("\n Information Technology MCA 101 40 100 %d",mca101);
printf("\n Mathematical Foundation MCA 102 40 100 %d",mca102);
printf("\n Programming in C MCA 103 40 100 %d",mca103);
printf("\n Computer Organization MCA 104 40 100 %d",mca104);
printf("\n Communication Skills MCA 105 40 100 %d",mca105);
printf("\n ---------------------------------------------------------------");
printf("\n TOTAL 200 500 %d",total);
printf("\n ---------------------------------------------------------------");
printf("\n # PERCENTAGE : %f % #",per);
getch();
}
Screen Print of program:
Please enter the marks of MCA 101 : 80
Please enter the marks of MCA 102 : 80
Please enter the marks of MCA 103 : 80
Please enter the marks of MCA 104 : 80
Please enter the marks of MCA 105 : 80
---------------------------------------------------------------------------------------------------------------
* MARKSHEET OF MCA - I SEM *
---------------------------------------------------------------------------------------------------------------
SUBJECT SUBJECT CODE MIN MAX MARKS OBTAINED
---------------------------------------------------------------------------------------------------------------
Intormation Technology MCA 101 40 100 90
Mathematical Foundation MCA 101 40 100 90
Programming in C MCA 101 40 100 90
Computer Organization MCA 101 40 100 90
Communication Skills MCA 101 40 100 90
---------------------------------------------------------------------------------------------------------------
TOTAL 200 500 450
---------------------------------------------------------------------------------------------------------------
2nd Assignment :
If basic salary is input through by the keyboard the DA is 40% of basic salary and HR is
20% of basic salary so write a program to calculate the gross salary.
#include<stdio.h>
void main()
{
float bs,da,hr,gs;
clrscr();
printf("Please enter the basic salary : ");
scanf("%f",&bs);
da=(bs*40)/100;
hr=(bs*20)/100;
gs=bs+da+hr;
printf("\n Basic Salary is = %f",bs);
printf("\n D.A. is = %f",da);
printf("\n H.R. is = %f",hr);
printf("\n ------------------------------------------------");
printf("\n Total gross salary is = %f",gs);
printf("\n ------------------------------------------------");
getch();
}
Screen Print of program:
If any integer is input through by the keyboard WAP to find it is an odd or even number.
#include<stdio.h>
void main()
{
int a;
clrscr();
printf("Please enter any inteager number : ");
scanf("%d",&a);
if(a%2==0)
printf("# The entered number is an even number #");
else
printf("# The entered number is an odd number #");
getch();
}
Screen Print of program:
If any year is input through by the keyboard WAP to find it is a leap year or not.
#include<stdio.h>
void main()
{
int y;
clrscr();
printf ("Please enter the year : ");
scanf("%d",&y);
if(y%100==0)
{
if (y%400==0)
printf("\n # The entered year is a leap year. # ");
else
printf("\n # The entered year is not a leap year. # ");
}
else
{
if (y%4==0)
printf("\n # The entered year is a leap year. # ");
else
printf("\n # The entered year is not a leap year. # ");
}
getch();
}
Screen Print of program:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[25][25];
int a1[25][25];
int a2[25][25];
int i,j,n,m,k,l,e;
clrscr();
printf("Enter the size of first matrix \n");
scanf("%d%d",&n,&m);
printf("\nEnter the elements of first matrix \n");
for(i=0;i<n;i++)
for(j=0;j<m;j++)
scanf("%d",&a[i][j]);
for(i=0;i<k;i++)
for(j=0;j<l;j++)
scanf("%d",&a1[i][j]);
for(i=0;i<n;i++)
{
for(j=0;j<k;j++)
{
a2[i][j]=0;
for(e=0;e<k;e++)
{
a2[i][j]=a2[i][j] + (a[i][e] * a1[e][j]);
}
}
}
printf(" Multiplication of matrixes is:\n");
for(i=0;i<n;i++)
{
for(j=0;j<l;j++)
getch();
}
Screen Print of program:
Example 1:
Example 2:
#include<stdio.h>
void main()
{
int a[25][25];
int i,j,n,m;
clrscr();
printf("Enter the size of matrix :\n");
scanf("%d%d",&n,&m);
printf("Enter the elements of matrix :\n");
for(i=0;i<n;i++)
for(j=0;j<m;j++)
scanf("%d",&a[i][j]);
printf("You entered the matrix :\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
printf("\t%d",a[i][j]);
printf("\n");
}
printf("The Transpose of this matrix is :\n");
for(j=0;j<m;j++)
{
for(i=0;i<n;i++)
printf("\t%d",a[i][j]);
printf("\n");
}
getch();
}
Screen Print of program:
//9 line
printline2();
//10 -14 line
for(i=0;i<5;i++)
{
printf("\n");
printline();
}
printf("\n");
//15 line
*
* *
* *
* *
* *
***************************************************************
*************************** G.G.C.T ***************************
* *********** *
* ********** ********** * * ********** ********** *
* * * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * *
* ********** ********** * * ********** ********** *
* ********** ********** * * ********** ********** *
* * * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * *
* ********** ********** * * ********** ********** *
***************************************************************
Screen Print of program:
/* A function program with arguments and no return value (Pro.-Sum of two values)*/
#include<stdio.h>
void sum(int a,int b)
{
printf("Enter the two values : \n");
scanf("%d %d",&a,&b);
printf("The sum of these two values is : %d",(a+b));
}
void main()
{
int x,y;
clrscr();
sum(x,y);
getch();
}
Screen Print of program:
/* A program of function with arguments and return value (Pro.-Find Largest value)*/
#include<stdio.h>
int larg(int x, int y)
{
(x>y)?x:y;
}
void main()
{
int a,b;
clrscr();
printf("Enter two values : \n");
scanf("%d %d",&a,&b);
printf("The largest value is : %d",larg(a,b));
getch();
}
Screen Print of program: