Professional Documents
Culture Documents
Assignment # 01: Students Name: Mashal Khalil
Assignment # 01: Students Name: Mashal Khalil
Code:
#include<iostream>
int main()
int year;
cin>>year;
else
return 0;
OUTPUT:
Task Title:
Write a program to find size of int, float and double variable
Code:
#include<iostream>
int main()
int sint,sfloat,sdouble;
sint=sizeof(int);
sfloat=sizeof(float);
sdouble=sizeof(double);
return 0;
OUTPUT:
Task Title:
Write a Program to print half pyramid a using mmhg uygt numbers:
Code:
#include<iostream>
int main()
for(int i=1;i<=5;i++)
for(int j=1;j<=i;j++)
cout<<i;
cout<<"\n";
return 0;
OUTPUT:
Task Title:
Write a Program to store value of two books in structure and then display it. (Book ID,
Book Name, Book Author, Book Subject):
Code:
Book.h:
struct Book
int Id;
char Name[50];
char Authorname[50];
char Subject[50];
};
Book.cpp
#include"Book.h"
#include<iostream>
using namespace std;
int main()
{
Book b1[50];
for(int i=0;i<2;i++)
{
cout<<"\n Enter the Id of Book: ";
cin>>b1[i].Id;
cout<<"\n Enter the Name of Book: ";
cin>>b1[i].Name;
cout<<"\n Enter the Name of Author of Book: ";
cin>>b1[i].Authorname;
cout<<"\n Enter the Subject of Book: ";
cin>>b1[i].Subject;
}
cout<<"\n __________________________________________ :";
for(int i=0;i<2;i++)
{
cout<<"\n Displaying Data :";
cout<<b1[i].Id<<endl;
cout<<b1[i].Name<<endl;
cout<<b1[i].Authorname<<endl;
cout<<b1[i].Subject<<endl;
}
return 0;
}
OUTPUT:
Task Title:
Store Information of student in a Structure and Display it. Student information should
contain his Name, Roll Number and Marks.
Code:
Student.h:
struct Student
{
int Rollno;
char Name[50];
int marks;
};
Student.cpp:
#include"Student.h"
#include<iostream>
using namespace std;
int main()
{
Student std;
cout<<"\n Enter the Roll no of student :";
cin>>std.Rollno;
cout<<"\n Enter the Name of student :";
cin>>std.Name;
cout<<"\n Enter the marks of student :";
cin>>std.marks;
cout<<"\n_______________________________\nDisplaying data:";
cout<<"\n Roll no:"<<std.Rollno;
cout<<"\n Name :"<<std.Name;
cout<<"\n Marks :"<<std.marks;
return 0;
}
OUTPUT: