Professional Documents
Culture Documents
SRM 1
SRM 1
COLLEGE OF ENGINNERING
DEPARTEMENT OF ELECTRICAL AND COMPUTER ENGINNERING
COURSE TITLE: INTRODUCTION TO COMPUTER PROGRAMMING
BASIC INSTRUCTIONS:
2). which one of the following statement terminates the switch, and flow of control
jumps to the next line following the switch statement?
3). If k=10; which of the following is false about the function y and the literal constant k?
A. cout>>’’hello’’;
B. double height, weight = 62.0, width;
C. double π = 3.14;
D. int 23birr;
#include <iostream>
using namespace std;
int main ()
{
int a = 5;
int b = 10;
cout <<( (a>b)?a:b);
return 0;
}
A. 5
B. 10
C. Syntax error
D. None of above
9). which of the following functions will correctly return true if its argument x is an odd integer?
Q1 OUTPUT
#include <iostream>
using namespace std;
int main()
{
int i=1,s = 0;
while (i<= 11)
{
s += i;
cout<<i<<" "<<s<<endl;
if(i==4)
break;
i++;
}
cout << "S = " << s<<endl;
cout << "i after loop = " <<i;
return 0;
}
Q3 OUTPUT
#include<iostream>
using namespace std;
int main()
{
int x=5,y=7,z;
z=x;
cout<<x<<y<<z<<endl;
cout<<++x+y<<endl;
z=x++;
cout<<x<<","<<z<<endl;
z=y++;
cout<<(x-y+z)<<endl;
cout<<”end\n”<<x<<endl<<y<<endl<<z;
return 0;
}
Q1 OUTPUT
#include< >
using namespace std;
double daverage(int x1, int x2)
{
av=(x1+x2)/2;
RETURN av;
}
int main()
{
double n1, n2;
cout>>”enter two numbers\n”>>;
cin>>n1;n2;
davrg= daverage(n1,n2);
cout<<davrg<<endl;
}
include<iostream>
using namespace std;
int main[]
{
integer sum
for[i=0; i<=100 i++];
{
sum =sum+i
}
cout>>sum
return 0;
Part Iv: Write a C++ program for the following questions. (12%)
Q2. Write a program that takes ten integer numbers from the user; calculates and display the sum and
average of those numbers (hint: use an array)