1)-Write a C- program for addition of n number .#java 8 download.
program for addition |
output of addition |
#include<stdio.h>
#include<conio.h>
Void main()
{
Int a,n,i,sum=0,;
Clrscr();
Printf(“Enter the number which you want to add \n”);
Scanf (“%d”,&n);
Printf(“Enter the numbers \n” );
For(i=1; i<=n; i++)
{
Scanf(“%d”,&a);
Sum=sum+a;
}
Printf(“After addition result=%d”,sum);
getch();
}
Input:- Enter the number which you want to add
4
Enter the numbers
1
2
3
4
2)- Write a C-language program for the Substraction of two numbers.
#include<stdio.h>
#include<conio.h>
Void main()
{
Int a,b,
Sub;
Clrscr();
Printf(“ Enter the number from which you want to
substract \n”);
Scanf(“%d”,&a);
Printf(“Enter the number which you want to substract \n”);
Scanf(“%d”,&b);
Sub=a-b;
Printf(“After Substraction result=%d”,Sub);
getch();
}
Input:-Enter the number from which you want to substract
65
Enter the number which you want to substract
4
output :-After Substraction result=61
program for substraction |
output |
3)- Write a C- program for Multiplication of n number.
#include<stdio.h>
#include<conio.h>
Void main()
{
Int
a,n,i, Multi=1,;
Clrscr();
Printf(“Enter the number which you want to multiply \n”);
Scanf (“%d”,&n);
Printf(“Enter the numbers \n” );
For(i=1;
i<=n; i++)
{
Scanf(“%d”,&a);
Multi =Multi * a;
}
Printf(“After
Multiplication result=%d”,Multi);
getch();
}
Input:-Enter the number which you want to multiply
4
Enter the numbers
1
2
3
5
output :-After Multiplication result=30
4)- Write a
C-language program for the division of two numbers.
#include<stdio.h>
#include<conio.h>
Void main()
{
float a,b, Div;
Clrscr();
Printf(“Enter the number which you want to divide \n”);
Scanf(“%f”,&a);
Printf(“Enter the number from which you want to
divide \n”);
Scanf(“%f”,&b);
Div=a/b;
Printf(“After division Result=%f”,Div);
getch();
}
Input:-Enter the number which you want to divide
20
Enter the number from which you want to divide
4
output :-After division Result= 5.00000
program for division |
Div output |
0 Comments