Exercise 4 N 5 Answer
Exercise 4 N 5 Answer
Exercise 4 N 5 Answer
1. State whether the below variables declaration is valid or not? If it’s invalid give a reason.
iv. A char
v. & char
#include <iostream.h>
void main()
{
float average;
int reminder, score1, score2, score3,score4;
score1=11;
score2=12;
score3=13;
score4=10;
score2=15;
cout<<”score1 = “<<score1<<endl;
cout<<”score2 = “<<score2<<endl;
cout<<”score3 = “<<score3<<endl;
cout<<”score4 = “<<score4<<endl;
}
Output
score1 = 11
score2 = 15
score3 = 13
score4 = 10
#include <iostream.h>
void main()
{
int num1, num2;
num1 = 10;
num2 = 15;
cout<<"num1 = "<<num1<<endl;
cout<<"num2 = "<<num2;
}
Output
#include <iostream.h>
void main()
{
float num1, num2,num3,num4,average;
average = (num1+num2+num3+num4)/4;
cout<<"average = "<<average;
}