Lab5
Dana alfozan
Sec:2011
Task1:
A)
#include<iostream>
using namespace std;
int main()
{
int x=0;
while (x<=9);
{
x++;
cout<<x<<endl;
}
return 0;
}
B)
#include <iostream>
using namespace std;
int main()
{
int x;
x=0;
while (x<4);
{
cout<<"i like c++"<<endl;
x++;
}
return 0;
}
Task2:
#include<iostream>
using namespace std;
int main ()
{
int i=0;
int sum=0,count;
cout<<"enter the number "<<endl;
cin>>count;
while(i<=count)
{
sum=sum+i;
i++;
}
cout<<sum;
return 0;
}
Task3:
#include<iostream>
using namespace std;
int main ()
{
int i=0;
if(1<=10)
{
cout<<"enter any number "<<endl;
cin>>i;
if(i%2==0)
cout<<"the number is even";
else if (i%2!=0)
cout<<"the number is odd";
i++;
}
else
cout<<"invalid number";
return 0;
}
Task4:
#include<iostream>
using namespace std;
int main ()
{
int i=20;
while(i>=0);
{
cout<<i;
i--;
}
return 0;
}
Task 5:
1)
12
14
16
18
20
22
2)
#include <iostream>
using namespace std;
void main()
{
int mark;
int pass,not_pass;
int i=0;
int number;
pass=0;
not_pass=0;
cout<<"enter number of student,its must be less 10"<<endl;
cin>>number;
while (i<number)
{
cout<<"enter the student marks "<<endl;
cin>>mark;
if (mark >=50)
pass=pass+1;
else
not_pass=not_pass+1;
i=i+1;
}
enter number of students, its must be less 10
2
enter the student marks
20
enter the student marks
56
3.
#include <iostream.h>
void main()
{ int a,b,c,max,i;
i=0;
max=0;
while (i<max)
{
i=1+i;
cout<<"enter the "<<i<<" number "<<endl;
cin>>a;
if (a>=max)
max=a;
}
cout<<"the max number is "<<max<<endl;
}
4.
#include <iostream>
using namespace std;
void main()
{ int a,max,i;
i=0;
max=0;
while (i<5)
{
cout<<"enter the "<<i<<" number "<<endl;
cin>>a;
if (a>=max)
max=a;
i=1+i;
}
cout<<"the max number is "<<max<<endl;
}
© Copyright 2026 Paperzz