Professional Documents
Culture Documents
Programming Fundanental 2
Programming Fundanental 2
Void main()
Int a,b,c,d,formula;
Cin>>a>>b>>c>>d;
Formula=a*b/(-c*31%13)*d
2. Write a program that display the sizes of different data types like char,int,..
#include<iostream.h>
Void main()
Cout<<”size of int”<<sizeof(int);
Cout<<size of float”<<sizeof(float);
Cout<<”size of char”<<sizeof(char);
Cout<<”size of double”<<sizeof(double);
}
3. Write a program that input salary and grade. It adds 50%bonus if the grade is
greater than 15. It adds 25%.....
#include<iostream.h>
Void main()
Cin>>grade>>salary;
If(grade>15)
Bonus=salary/2;
Total=salary + bonus;
Else(grade>=15)
Bonus=salary/4;
Total=salary+bonus;
}}
4. Write a program that display either the number entered is a even or odd…
#include<iostream.h>
Void main()
{
Int num1;
Cin>>num1;
5. Write a program that input are even odd number, multiply the even number…
#include<iostream.h>
Void main()
Cin>>even;
Cin>>odd;
Multiply1=even +5;
Multiply2=odd+7;
Add= multiply1+mulyiply2;
Subtract= add-1000;
#include<iostream.h>
Void main()
{
Int num1,num2,num3,num4,num5,greatest,smallest;
Cin>>num1>>num2>>num3>>num4>>num5>>;
if(num1>greatest)
Cout<<greatest=num1;
If(num2>greatest)
Cout<<greatest=num2;
If(num3>greatest)
Cout<<greatest=num=3;
If(num4>greatest)
Cout<<greatest=num4;
If(num5>greatest)
Cout<<greatest=num5;
If(num1<smallest)
Cout<<smallest=num1;
If(num2<smallest)
Cout<<smallest=num2;
If(num3<smallest)
Cout<<smallest=num3;
If(num4<smallest)
Cout<<smallest=num4;
If(num5<smallest)
Cout<<smallest=num5;
7. Write a program that display first ten number with their square while loop
#include<iostream.h>
Void main()
Int i=1;
While(i<=10)
Cout<<”i/t i /t/n”,i,i*i;
i=i++;
8. Write a program that display the product of all odd number from 1 to 10 using
for loop
#include<iostream.h>
Void main()
Int product,i;
For(i=1; i<=10;i+=2)
Product=product*I;
Cout<<”result=”<<product;
}
9. Write a program which take starting and ending numbers and then print the odd
number ranges in those numbers
Int i, j;
Cin>>I;
Cin>>j;
Do
If(i%2!=0)
I=i++;
While(i<=j)
*****
*****
*****
*****
*****
#include<iostream.h>
Void main()
{
Int i,j;
Cout<<”*”;
Cout<<”/t”;
12345
12 3 4
123
12
#include<iostream.h>
Void main()
Int I,j;
For(j=1;j<=I; j++)
Cout<<j;
}
Cout<<”/t”;
4444
333
22
#include<iostream.h>
Void main()
{ int I,j;
For(j=1;j<=I;j++)
Cout<<”j”;
Cout<<”/t”;
#include<iostream.h>
Void main()
{
Int I,j,k;
For(i=1; i<=3;i++)
For(j=1;j<=3;j++)
For(k=1;k<=3
{cout<<i<<j<<k;
Cout<<”/t”;
14. Write a program that input and display the factorial of that number using while
loop
#include<iostream.h>
Void main()
Int n;
Cin>>n;
While(c<=n)
{
P=p*c;
C++;
Cout<<”fact of n:”<<p;