Professional Documents
Culture Documents
CS-I Practicals Answer Key 11th
CS-I Practicals Answer Key 11th
CS-I Practicals Answer Key 11th
Aim: Write a program in C++ to display a message as “Welcome to C++ programming. C++ is
better than C.”
Note: - Write the below answer on proper printout of Practical file sheet.
Output:
Note: - Write the below answer on proper printout of Practical file sheet.
Output:
Enter first integer number
10
Enter second integer number
5
Enter operator
+
Result: 10+5 = 15
Experiment No. 03:- Study of C++ Program using Control Structure.
Aim: Write a program in C++ to Display Odd numbers between 1 to 100 using loop”
Note: - Write the below answer on proper printout of Practical file sheet.
#include <iostream>
int main() {
int num,i,cnt;
i=0;
num=100;
cnt=0;
for(i;i<=num;i++){
if(i%2!=0){
cnt=cnt+1;
cout<<i<<"\t";
if(cnt==10){
cnt=0;
cout<<endl;
return 0;
}
Output:
1 3 5 7 9 11 13 15 17 19
21 23 25 27 29 31 33 35 37 39
41 43 45 47 49 51 53 55 57 59
61 63 65 67 69 71 73 75 77 79
81 83 85 87 89 91 93 95 97 99
Experiment No. 04:- Study of C++ Program using functions.
Aim: Write a program in C++ to interchange two integer numbers using call by reference.”
Note: - Write the below answer on proper printout of Practical file sheet.
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;
void swap(int *,int *);
int main() {
int num1,num2;
cout<<"Enter first number"<<endl;
cin>>num1;
cout<<"Enter second number"<<endl;
cin>>num2;
cout<<"Numbers before swapping: Num1= " <<num1<<" and Num2=
"<<num2<<endl;
swap(&num1,&num2);
cout<<"Numbers After Swapping, Num1="<<num1<<" and Num2=
"<<num2;
return 0;
}
void swap(int *x,int *y){
int temp;
temp=*x;
*x=*y;
*y=temp;
}
Output:
10
15
#include <iostream>
using namespace std;
void swap(int,int);
int main() {
int num1,num2;
cout<<"Enter first number"<<endl;
cin>>num1;
cout<<"Enter second number"<<endl;
cin>>num2;
cout<<"Numbers before swapping: Num1= " <<num1<<" and Num2=
"<<num2<<endl;
swap(num1,num2);
return 0;
}
void swap(int x,int y){
int temp;
temp=x;
x=y;
y=temp;
cout<<"Numbers After Swapping, Num1="<<x<<" and Num2= "<<y;
}
Output:
return 0;
}
Output:
Enter element 1 : 2
Enter element 2 : 4
Enter element 3 : 6
Enter element 4 : 8
Enter element 5 : 10
#include <iostream>
int main() {
int cnt=1;
for(int i=0;i<=15;i++){
cout<<i<<"\t";
if(cnt%4==0)
cout<<endl;
cnt++;
return 0;
Output:
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
Experiment No. 08:- Study of C++ programming.
Aim: Write a program in C++ to draw a right angle triangle with ‘*’.
Note: - Write the below answer on proper printout of Practical file sheet.
int main() {
char ch='*';
int size;
cout<<"Enter the length of side ";
cin>>size;
for(int i=1;i<=size;i++){
for(int j=0;j<i;j++){
cout<<ch<<ends;
}
cout<<endl;
}
return 0;
}
Output:
Enter the length of side 4
*
* *
* * *
* * * *
Experiment No. 09:- Study of Visual Basic Application.
Aim: Write a program in VB to calculate sum of numbers within a range using loop.”
Note: - Write the below answer on proper printout of Practical file sheet.
Private Sub Command1_Click()
Dim sum As Double
Dim k As Integer
Sum=0
i=Text1.Text
j=Text2.Text
k=i
while k<= j
sum=sum+k
k=k+1
wend
Text3.Text=sum
End Sub
Experiment No. 10:- Study of Visual Basic Addition/Substraction Application.
Aim: Write a program in VB to design application window.”
Note: - Write the below answer on proper printout of Practical file sheet.