Professional Documents
Culture Documents
CSC241 - Introducti On Program Ming II: Jahan Institute of Higher Education Department of Computer Sciences
CSC241 - Introducti On Program Ming II: Jahan Institute of Higher Education Department of Computer Sciences
CSC241 - Introducti On Program Ming II: Jahan Institute of Higher Education Department of Computer Sciences
JAHAN
INSTITUTE
OF HIGHER
EDUCATION
Department
of Computer
Sciences
CSC241
Introducti
on
Program
ming II
Name:
Registration ID:
Assignmen
t2
(b)
(c)
(d)
MAIN()
{
cout(Hello world;
}
int x = 5;
if ( x = 6 )
cout<<x is equal to,x;
int area;
{
return 0;
printf("%c", NEWLINE);
}
Q5: Write a program to find out the binary number of a decimal number.
#include <iostream.h>
#include <conio.h>
int main()
{
long intd,q;
int b[100],i=1,j;
cout<<"enter decimal number ";
cin>>d;
q = d;
while (q!=0) {
b[i++]=q%2;
q=q/2;
}
for(j=i-1;j>0;j--)
cout<<b[j];
getch();
}
After fix
#include <iostream.h>
int main()
{
int num1, num2,num3;
cout<<" Enter value for first
number";
cin>>num1;
cout<<" Enter value for second
number";
cin>>num2;
cout<<" Enter value for third
number";
cin>>num3;
if(num1>num2&&num1>num3)
{
cout<<" First number is
greatest:"<<endl<<"whick is=
"<<num1;
elseif(num2>num1&&num2>num3)
{
Cout<" Second number is
greatest"<<endl<<"whick is=
"<<num2;
}}
else
{
cout<<" Third number is
greatest"<<endl<<"whick is=
"<<num3;
}
return 0;
}
}
else if(num2>num1&&num2>num3)
{
cout<<"Second number is
greatest"<<endl<<"whick is=
"<<num2;
}
else
{
cout<<" Third number is
greatest"<<endl<<"whick is=
"<<num3;
}
return 0;
}
auto
register
static
extern
}
The example above defines two variables with the same storage class, auto can only
be used within functions, i.e., local variables.
#include <iostream>
// Function declaration
voidfunc(void);
Thank You!!!