Itc All Asigment
Itc All Asigment
use exercise
Update exercise_logss
set
calories = 190,
heart_rate = 80
where
id = 3
Lab Task. 7.1) Write a program which prints your bio data and also show it
#include <iostream>
int main()
{ int
a=0;
std::string b;
cout << "Enter your name" << endl;
getline(cin,b);
cout << "Enter your CMS ID" << endl;
cin >>a;
return 0;
}
Lab Task. 7.2) Write a program that prints the table of 8. Sample Output
#include <iostream>
using namespace std;
int main()
{
int a;
cout << "Tables" << endl;
cout <<"Enter Number"<< endl;
cin >>a;
cout <<a<<" x 1 = "<<a*1<< endl;
cout <<a<<" x 2 = "<<a*2<< endl; cout
<<a<<" x 3 = "<<a*3<< endl; cout
<<a<<" x 4 = "<<a*4<< endl; cout
<<a<<" x 5 = "<<a*5<< endl; cout
<<a<<" x 6 = "<<a*6<< endl; cout
<<a<<" x 7 = "<<a*7<< endl; cout
<<a<<" x 8 = "<<a*8<< endl; cout
<<a<<" x 9 = "<<a*9<< endl; cout
<<a<<" x 10 = "<<a*10<< endl; cout
<<a<<" x 11 = "<<a*11<< endl; cout
<<a<<" x 12 = "<<a*12<< endl;
return 0;
}
Lab Task. 7.3) Write a program which reads marks for three subjects and then prints total
marks and percentage.
return 0;
}
LAB TASK 8:
ITC LAB 8
Lab Task. 8.1) Write a program that inputs, three numbers and find the greatest numbers
among these numbers.
#include <iostream>
using namespace std;
int main()
{ int a,b,c;
cout <<"Enter First number" << endl;
cin >>a;
cout <<"Enter Second number" <<endl;
cin >>b;
cout <<"Enter Third number" << endl;
cin >>c; if ((a>b) && (a>c))
cout<<"The Greatest number is "<<a<< endl;
else if ((b>a) && (b>c))
cout<<"The Greatest number is "<<b<< endl;
else
cout<<"The Greatest number is "<<c<< endl;
return 0;
}
Lab Task. 8.2) Write a program that swaps the value of two variables using a third variable
#include <iostream>
using namespace std;
int main()
{ int a, b, c;
cout<<"enter 1st number; ";
cin>>a;
cout<<"Enter 2nd Number: ";
cin>>b;
cout<<"Before Swapping"<<endl;
cout<<"First Number "<<a<<endl;
cout<<"Second number "<<b<<endl;
c=a;
a=b;
b=c;
cout<<"After Swapping"<<endl;
cout<<"First Number "<<a<<endl;
cout<<"Second number "<<b<<endl;
return 0;
}
Lab Task. 8.3) Write a program that checks whether the entered year is a leap year or not
#include <iostream>
using namespace std;
int main()
{ int a; cout<<:enter a year” << endl ;
cin>>a; if((a%4==0)) cout <<a<<”is a
leap year”<<endl; else cout<<a<<”a is
not a leap year”<<endl; return 0
}
Lab Task. 8.4) Write a program that checks whether the entered number is positive or
negative.
#include <iostream>
using namespace std;
int main()
{ int
a;
cout<<"Enter a Number" <<endl;
cin>>a;
if ((a>=0))
cout <<a<<" is a positive number"<<endl;
else
cout <<a<<" is a negative number"<<endl;
return 0;
}
LAB 9
Lab Task 9.1) Write a program that prints the area and the parameter of the rectangle
#include <iostream>
using namespace std;
int main()
{ int a,b,c,d;
cout << "Enter Hight of Rectangle " << endl; cin >> a;
cout << "Enter width of Rectangle " << endl; cin >>
b; c=a*b;
cout << "Area of Rectangle is "<<c<< endl; d=2*(a+b);
cout << "Parameter of Rectangle is "<<d<< endl; return 0;
}
Lab Task 9.2) Write a program that checks whether the entered alphabet is a vowel or
not.
#include <iostream>
using namespace std;
int main()
{ char c;
int islowercaseVowel, isUppercaseVowel;
if (islowercaseVowel || isUppercaseVowel)
cout << c << " is a Vowel."; else
cout << c << " is not a Vowel.";
return 0;
}
Lab Task 9.3) Write a program that checks whether the number entered as input is
odd or even.
#include <iostream>
using namespace std;
int main()
{ int a;
cout << "Enter a number " << endl;
cin >> a;
if ((a%2==0))
cout <<a<< " is an even number."; else
cout << a << " is an odd number.";
return 0;
}
Lab Task 9.4) Write a program that takes two numbers as input and then calculate
and print the sum, difference, product and quotients of these two numbers
#include <iostream>
using namespace std;
int main()
{
float a,b,c,d,e,f,g,h;
cout << "Enter First number " << endl; cin >> a;
cout << "Enter second number " << endl; cin >>
b; d=a+b;
cout << "Sum: "<< d << endl; f=a-b;
cout << "Difference: "<< f << endl; g=a*b;
cout << "Product: "<< g << endl; h=a/b;
cout << "Quotient: "<< h << endl;
return 0;
}
LAB 10
Lab Task. 10.1) Write a program that inputs, user grade A to F and display its comments
according to grade entered.
int main()
{
char Grade;
cout << "Enter your grade (A-F)" << endl;
cin>> Grade;
// while(Grade>=A&&Grade<=F)
{
switch(Grade)
{ case 'A':
cout<<"Your grade is A.\n";
cout<<"Excellent.\n";break; case 'B':
cout<<"Your grade is B.\n";
cout<<"Very Good.\n";break; case 'C':
cout<<"Your grade is C.\n";
cout<<"Good.\n";break; case 'D':
cout<<"Your grade is D.\n";
cout<<"Satisfactory.\n";break; case 'E':
cout<<"Your grade is E.\n";
cout<<"Unsatisfactory.\n";break; case 'F':
cout<<"Your grade is f.\n";
cout<<"Fail.\n";break; case 'a':
cout<<"Your grade is a.\n";
cout<<"Excellent.\n";break;
case 'b':
cout<<"Your grade is b.\n";
cout<<"Very Good.\n";break; case 'c':
cout<<"Your grade is c.\n";
cout<<"Good.\n";break; case 'd':
cout<<"Your grade is d.\n";
cout<<"Satisfactory.\n";break; case 'e':
cout<<"Your grade is e.\n";
cout<<"Unsatisfactory.\n";break; case 'f':
cout<<"Your grade is f.\n";
cout<<"Fail.\n";break; default:
cout<<"Wrong Grade \n"<<endl;
}
//cout<<"Enter your grade (A-F)";
//cin>>Grade;
} return 0;
}
Lab Task. 10.2) Write a program that ask user for which shape you want to calculate area
(Example Circle, square and triangle) and then take appropriate input from user to
calculate.
switch (shape)
{
case square: cout << "Enter the length of the side of the square in meters " <<
endl; cin>>a; area=a*a;
cout<<"area of Square is "<<area<<endl;
break; case triangle: cout << "Enter the width of the
triangle" << endl; cin>>a;
cout << "Enter the Height of the triangle " << endl;
cin>>b; area=(a*b)/2;
cout<<"area of Triangle is "<<area<<endl;
break; case circle:
cout << "Enter the radius of the circle " << endl; cin>>r;
area=3.15*(r*r);
cout<<"area of circle is "<<area<<endl;
break; case rectangle: cout << "Enter the height of the
rectangle" << endl; cin>>a;
cout << "Enter the width of the rectangle " << endl;
cin>>b; area=a*b;
cout<<"area of rectangle is "<<area<<endl;
break; default:
cout << "Invalid input" << endl;
return -1;
}
return 0;
}
Lab 11
Lab Task 11.1) Write a program to calculate the factorial of the input number.
Lab Task 11.2) Write a program to check the input is a prime number or not.
#include <iostream>
int main()
{
int a,b=0,c=0,i;
cout << "Enter a number " << endl;
cin>>a;
c=a/2;
for(i=2; i<=c; i++ )
{
if(a%i==0)
{
cout<<"number is not a prime."<<endl;
b=1;
break;
}
}
if(b==0)
cout<<"number is prime."<<endl;
return 0;
}
Lab Task 11.3) Write a program to generate a Fibonacci Series of given number of terms
#include <iostream>
using namespace std;
int main()
{
int n, t1 = 0, t2 = 1, nextTerm = 0;
#include <iostream>
using namespace std;
int main()
{
int a,b;
for (int a=1; a<=5; a++ ) //for no of rows
{
for (int b=1; b<=a; b++ ) //for number of colunms
{
cout<<b;
}
cout <<"\n"; //to jump to next line after a loop
}
return 0;
}
LAB 12
Lab Task. 12.1) Write a program to generate a number table of the given value. The user
should be asked for RE-RUN or EXIT the program giving up the following massage; “Do
You Want To Continue (Y/N)”.
#include <iostream>
using namespace std;
cout << "Enter the number of the required table: "; cin
>> n;
Lab Task. 12.2) Write a program to find a factorial using while loop.
Lab Task. 13.2) Write a program that input the marks of five students in an array and find
the average
Lab Task. 13.3) Write a program that creates an array of 8 numbers and perform the
following:
a. Input a number from user and search in array if it is
present or not.
b. Find the highest number present in array.
c. Find the lowest number present in array.
# include <iostream> using
namespace std;
1int main()
{
int a[8],inp;
char opt;
switch(opt)
{
case 'a':
cout << "Enter any number :" << endl;
cin >> inp;
if(inp == a[0] || inp == a[1] || inp == a[2] || inp == a[3] || inp == a[4] || inp == a[5] || inp == a[6]
|| inp == a[7] )
{
cout << "Number is present in array" << endl;
}
else
{
cout << "Number doesn't present in array" << endl;
}
break;
case 'b':
for(int i =0; i <=7 ; i++)
{
if(a[0] < a[i])
{
a[0] = a[i];
}
}
cout << "Highest number is" << a[0] << endl;
break;
case 'c':
for(int i =0; i <=7 ; i++)
{
if(a[0] > a[i])
{
a[0] = a[i];
}
}
cout << "Lowest number is" << a[0] << endl;
break;
}
}
Lab Task. 13.4) Using two-dimensional arrays, write a program which sums two (2x2)
matrices of integers
#include <iostream>
using namespace std;
int main()
{
int r, c, a[100][100], b[100][100], sum[100][100], i, j;
cout << endl << "Enter elements of 1st matrix: " << endl;
return 0;
}
Lab Task. 13.5) Write a program to print the given numbers in ascending order using
arrays.
#include <iostream>
using namespace std;
int main()
{
//array declaration
int arr[MAX];
int n,i,j;
int temp;
//check bound
if(n<0 || n>MAX)
{
cout<<"Input valid range!!!"<<endl;
return -1;
}
//read n elements
for(i=0;i<n;i++)
{
cout<<"Enter element ["<<i+1<<"] ";
cin>>arr[i];
}
return 0;
}
LAB 14
Lab Task. 14.1) Write a program in python to add, subtract, multiply and divide 2 input numbers.
x=int(input("enter a number:"))
y=int(input("enter a another
number:")) print("X + Y =",x+y)
print("X - Y =",x-y) print("X * Y
=",x*y) print("X / Y =",x/y)
Lab Task. 14.2) Write a program in python to display a table of input number.